Synopsis: Easier specification of bitfield values. July 96 Date: Tue, 9 Jul 1996 21:42:22 +0200 (MET DST) From: erwin@pip.dknet.dk To: MERC/Envy Mailing List Subject: Bits! I got tired of computing 2^28, so I defined this: It's not a novel idea, as Russ has already done something much like this for ROM, but I like numbers better than letters.. :) His system, however, has the advantage that flags are saved as letters, so you can quickly find out what 'E' on act means. I'm planning to save the whole word instead, so that the format becomes truly bit-independent. But under any circumstances, typing: #define COMM_NEW_FANCY_CHANNEL BIT_18 is better than finding the next power of 2 :) If you change your current act/aff/etc. bits to these new defines, to more easily see what bit to use next, be careful to make sure that you use exactly the same values. Oh, and note that the values themselves are in hexadecimal. This is was what I used to do, before I decided to define all bits in a central place (even though 0x8000000 is easier to type than some decimal number, BIT_20 is even easier :) And yes, you could use something like (1 << 15) as well - but when I thought of that, I was too far in the table :) PS: If you tried getting files of pip.dknet.dk/pub/pip1773 and couldn't - well, it's fixed now. The permission were incorrect. I've also fixed and updated my home page :) {bitvalues.h} /* This file contains all the bits, making it easier to create those bfields */ #define BIT_0 0x00000001 /* 1 */ #define BIT_1 0x00000002 /* 2 */ #define BIT_2 0x00000004 /* 4 */ #define BIT_3 0x00000008 /* 8 */ #define BIT_4 0x00000010 /* 16 */ #define BIT_5 0x00000020 /* 32 */ #define BIT_6 0x00000040 /* 64 */ #define BIT_7 0x00000080 /* 128 */ #define BIT_8 0x00000100 /* 256 */ #define BIT_9 0x00000200 /* 512 */ #define BIT_10 0x00000400 /* 1 024 */ #define BIT_11 0x00000800 /* 2 048 */ #define BIT_12 0x00001000 /* 4 096 */ #define BIT_13 0x00002000 /* 8 192 */ #define BIT_14 0x00004000 /* 16 384 */ #define BIT_15 0x00008000 /* 32 768 */ #define BIT_16 0x00010000 /* 65 536 */ #define BIT_17 0x00020000 /* 131 072 */ #define BIT_18 0x00040000 /* 262 144 */ #define BIT_19 0x00080000 /* 524 288 */ #define BIT_20 0x00100000 /* 1 048 576 */ #define BIT_21 0x00200000 /* 2 097 152 */ #define BIT_22 0x00400000 /* 4 194 304 */ #define BIT_23 0x00800000 /* 8 388 608 */ #define BIT_24 0x01000000 /* 16 777 216 */ #define BIT_25 0x02000000 /* 33 554 432 */ #define BIT_26 0x04000000 /* 67 108 864 */ #define BIT_27 0x08000000 /* 134 217 728 */ #define BIT_28 0x10000000 /* 268 435 456 */ #define BIT_29 0x20000000 /* 536 870 912 */ #define BIT_30 0x40000000 /* 1 073 741 824 */ /* the 31st is the sign bit - we'll leave it alone */ ============================================================================== Erwin Andreasen Viby J, Denmark Computer Science Student at Aarhus Business 4u2@aabc.dk Click here! College ==============================================================================