Re: [Circle] BitVectors

From: Bri - Circle List (palin-c@lance.ij.net)
Date: 11/15/96


> 	When defining bitvectors... I noticed that the stock code usually has the
> number go from 1,2,4,8... but there usually is only about 4 options, so it
> only goes to about 4 - 8. But now I've added more #defines and if I follow
> the pattern of doubling the number, I get all the way up to 131072... Now I
> dont know if its just me, or that's absolutely wrong. So I guess my
> question is, do you HAVE TO double the numbers like they have it done, or
> can I just go 1,2,3,4,5 and so on to 15 without getting such a large number?
> 
The whole idea behind bitvectors can be summed up in the 8,4,2,1 idea.
This is that, with 15, you can toggle any idea of 8, 4, 2, or 1...
Computers work with switches, two positions: ON and OFF. This is known as
binary... When you have a bitvector, it looks like this:

00000000000000000000000000000000

That's 32 zeroes. Now, 1 would make this:
00000000000000000000000000000001

2 would show..
00000000000000000000000000000010

3 is:
00000000000000000000000000000011

To go back to the 8421 idea...

 1	0001		 2	0010		 3	0011
 4	0100		 5	0101		 6	0110
 7	0111		 8	1000		 9	1001
10	1010		11	1011		12	1100
13	1101		14	1110		15	1111

See how this works? So, if you were to say that such a flag is 15...
well, the computer would interpret a bitvector number of 15 (1111) as 8,
4, 2, and 1.

Hope this helps..:)

Bri

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST