Understanding bitwise code
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
It's not really a sign bit.. In that case you would end up with 2 representations for 0
) It's 2-complement representation... But there are only 2^16 positive numbers (and null) that you can represent with 32 bits. (See also: http://www.php.net/int).
Thus, the problem is that, when you add another security option, you don't know for sure what the result will be.The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). PHP does not support unsigned integers.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
My badtimvw wrote:It's not really a sign bit.. In that case you would end up with 2 representations for 0) It's 2-complement representation... But there are only 2^16 positive numbers (and null) that you can represent with 32 bits. (See also: http://www.php.net/int).
Thus, the problem is that, when you add another security option, you don't know for sure what the result will be.The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). PHP does not support unsigned integers.
d11wtq, don't give up so easy.
One bit is the sign and the other 31 are the value.
And that's what was quoted from the manual
No, with 32 bits you can represent the values -2^31 to (2^31)-1 or -2,147,483,648 to 2,147,483,647timvw wrote:But there are only 2^16 positive numbers (and null) that you can represent with 32 bits.
One bit is the sign and the other 31 are the value.
And that's what was quoted from the manual
From the small amount of code shown I think it's safe to add another power of two to the array.(See also: http://www.php.net/int).
Thus, the problem is that, when you add another security option, you don't know for sure what the result will be.The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). PHP does not support unsigned integers.
(i was mistaken) You're right that one can represent 2^31 -1 positive numbers with 32bits.sheila wrote:d11wtq, don't give up so easy.
No, with 32 bits you can represent the values -2^31 to (2^31)-1 or -2,147,483,648 to 2,147,483,647timvw wrote:But there are only 2^16 positive numbers (and null) that you can represent with 32 bits.
One bit is the sign and the other 31 are the value.
(you are mistaken) If one bit is the sign then you end up with -0 and +0 .
((http://en.wikipedia.org/wiki/Two%27s_complement)
You're right. But then again, it looks like there's plenty of room to add another permission, because summing all the permissions up (=43148) and adding 65536 (next permission value) is equal to 108684. And if the integer limit of PHP is 2,147,483,647 then there's plenty of room to expand (108684 is smaller than 2,147,483,647 if you missed the pointtimvw wrote:If one bit is the sign then you end up with -0 and +0 .