General Category > Ongoing Anim8or Development
ASL integer bit-wise operators
Raxx:
Hum...it works, apparently as it should. I think I'm just a little confuzzled about the bitwise NOT operation overall. Time to read up on it!
Thanks Claude, simplifies things tremendously.
Claude:
Sorry,didn't have much time when I posted.
In case this 0xffffffff is the confusing part,I should explain.
In ASL, an int is a 32-bit signed integer. Constants may be hexadecimal.
So,we define our constant as 0xffffffff
0x indicates that the following characters are hexadecimal.
Each character represents 4 bits(4 zeros or ones).
Example:
--- Code: ---0x0 0 0 0 0 f c 6
0000 0000 0000 0000 0000 1111 1100 0110
--- End code ---
Read the first 2 paragraphs and look at the table lower on the right
side.
http://en.wikipedia.org/wiki/Hexadecimal
So, 0xffffffff gives us a 32 bits of 1.
If you already knew,it's OK.It might help someone else
interrested in ASL.
Raxx:
Hey Claude, nice explanation. I pretty much knew that part (a good refresher though ;)), but like you said it could help someone else.
My main confusion was, I thought NOT was supposed to flip just the numbered bits, not the entire 32-bit span.
For example, my assumption was:
Int: 244 (0xf4)
Normal: [0000 0000 0000 0000 0000 0000] 1111 0100
Assumed NOT: [0000 0000 0000 0000 0000 0000] 0000 1011
Actual NOT: [1111 1111 1111 1111 1111 1111] 0000 1011 (int value: -245)
Claude:
I understand.
In C and C++,the bitwise complement operator flips every bit.
Since ASL most of the time follows the same rules,
we may assume that it will be like that.
The XOR operation is used as a sort of selective
complement operator.
Bitwise operators are not something I've used very often.Feels like a refresher course to me too.
Bye
Claude
Steve:
I forgot about ~. I'll add it.
(I guess I should look at the C++ spec occasionally instead of trying to remember everything myself - getting too old for that!)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version