0 registered members (),
984
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Tutorial: bitwise"&" operator use, **very usef
[Re: fastlane69]
#18997
12/02/03 08:30
12/02/03 08:30
|
Joined: Sep 2003
Posts: 9,859
FBL
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 9,859
|
I haven't tried, but normally it's open to interpretation, whether a number is positive or not.
A5 uses a fixpoint format, I think it was 22.10
This means we have a size of 4 byte, this is 32 bits.
The last 10 (1024 combinations, makes 3 decimal places) bits are taken for the positions after the decimal point, the remaining 22 bits are used for the positions before the decimal point.
With this format, we can store numbers, but there is no informations about the sign yet.
To get negatvie and positive numbers, the highest bit is used. A 1 means negatvie number, a 0 means negative number.
You might think we lose a lot of place with this as we only have 21 (2097152 combinations) instead of 22 (4194304) bits. That is not true. In fact we only moved the area where we can store numbers. We can't use that high positive nubmers anymore, therefore we can store negative numbers. It's all a question of interpretation.
(The fixpoint format of A5/6 might differ from 22.10, I don't know it out of my mind right now. The idea behind it is the same, it only changes the maximum number sizes/precision before and behind the decimal point. Maybe Conitec also uses some of the leading bits as variable flags like the info flag, I guess you will have to ask Conitec about that for more details)
|
|
|
Re: Tutorial: bitwise"&" operator use, **very useful**
[Re: Rhuarc]
#19000
12/19/03 03:43
12/19/03 03:43
|
Joined: Oct 2003
Posts: 1,550 United Kingdom
indiGLOW
Serious User
|
Serious User
Joined: Oct 2003
Posts: 1,550
United Kingdom
|
Give that man a round of applause.... The implications of this if used properly is huge.... I gave you 5 stars and I would have given more. THIS IS the most informative post @ this forum I have read!
It has so many uses, and the bandwidth saved? well it could make multiplay very effecient....
Thanks for making the obvious so clear.
The Art of Conversation is dead : Discuss
|
|
|
Re: Tutorial: bitwise"&" operator use, **very useful**
[Re: indiGLOW]
#19001
12/23/03 02:04
12/23/03 02:04
|
Joined: Mar 2001
Posts: 3,298 Beverly, Massachusetts
Rhuarc
OP
Expert
|
OP
Expert
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
|
Hehe, thanks man. I actually am looking at ways to compress the number (might have to go to a dll) into a smaller variable type for multiplayer use. Also, there are methods to store *multiple* strings of flags within it by adding other non-square numbers, but I'm still trying to sort that one out in my head. Thats when you get into prime numbers and such. (eyes start rolling in different directions....) I hope I'm on the right track . -Rhuarc
|
|
|
Re: Tutorial: bitwise"&" operator use, **very usef
[Re: Rhuarc]
#19002
12/17/05 17:35
12/17/05 17:35
|
Joined: Oct 2003
Posts: 1,550 United Kingdom
indiGLOW
Serious User
|
Serious User
Joined: Oct 2003
Posts: 1,550
United Kingdom
|
Wow, almost 2 years ago I read this post! Here I am all that time later returning to it. Fantastic! Everyone should read this, at least twice! lol
The Art of Conversation is dead : Discuss
|
|
|
Re: Tutorial: bitwise"&" operator use, **very usef
[Re: indiGLOW]
#19003
12/19/05 02:52
12/19/05 02:52
|
Joined: Jul 2002
Posts: 2,813 U.S.
Nadester
Expert
|
Expert
Joined: Jul 2002
Posts: 2,813
U.S.
|
I'd yell at you for reviving an old topic, but I'm not going to because this is a very important subject But so much more could be said about bitwise operations. A better way to set and turn off specific bits than what rhuarc said is like below: // maybe give these names for when you set skill flags #define bit0, 0x1; #define bit1, 0x2; #define bit2, 0x4; #define bit3, 0x8; #define bit4, 0x10; #define bit5, 0x20; #define bit6, 0x40; #define bit7, 0x80; var flags; // turn a bit on... function turnbiton() { flags|=BIT0; flags|=(BIT1|BIT2|BIT3|BIT4); } // turn bit off function turnbiton() { flags&=^BIT5; flags&=^(BIT1|BIT2|BIT3|BIT4); }
--Eric
|
|
|
|