Page 2 of 2

Posted: Tue Jan 31, 2006 1:36 pm
by timvw
That is because in php an unsigned integer is usually 32bits (thus 16 bits for positive numbers)... And your array is already using these.. 2^16 = 32768...

Posted: Tue Jan 31, 2006 1:39 pm
by pilau
So there shouldn't be a problem then, right?

Posted: Tue Jan 31, 2006 1:50 pm
by josh
Timvw, you said it's an un-signed 32 bit integer but if it is positive it is only 16 bits, how that work? If it's 32 bits un-signed (meaning positive numbers) couldn't it go to 2^32 ?

Posted: Tue Jan 31, 2006 2:01 pm
by Chris Corbyn
Now I'm getting confused.

Unsigned is 32 bits yes. Signed is *not* 16 bits last I checked... it's still 32 bits but one of those bits is the sign bit so the number is smaller.

Posted: Tue Jan 31, 2006 5:08 pm
by timvw
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).
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.
Thus, the problem is that, when you add another security option, you don't know for sure what the result will be.

Posted: Tue Jan 31, 2006 5:44 pm
by Chris Corbyn
timvw 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).
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.
Thus, the problem is that, when you add another security option, you don't know for sure what the result will be.
My bad :oops: Hey I'm still a n00b and everybody knows it :P :lol:

Posted: Tue Jan 31, 2006 10:19 pm
by sheila
d11wtq, don't give up so easy.
timvw wrote:But there are only 2^16 positive numbers (and null) that you can represent with 32 bits.
No, with 32 bits you can represent the values -2^31 to (2^31)-1 or -2,147,483,648 to 2,147,483,647
One bit is the sign and the other 31 are the value.

And that's what was quoted from the manual
(See also: http://www.php.net/int).
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.
Thus, the problem is that, when you add another security option, you don't know for sure what the result will be.
From the small amount of code shown I think it's safe to add another power of two to the array.

Posted: Wed Feb 01, 2006 4:37 am
by timvw
sheila wrote:d11wtq, don't give up so easy.
timvw wrote:But there are only 2^16 positive numbers (and null) that you can represent with 32 bits.
No, with 32 bits you can represent the values -2^31 to (2^31)-1 or -2,147,483,648 to 2,147,483,647
One bit is the sign and the other 31 are the value.
(i was mistaken) You're right that one can represent 2^31 -1 positive numbers with 32bits.
(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)

Posted: Wed Feb 01, 2006 6:24 am
by pilau
timvw wrote:If one bit is the sign then you end up with -0 and +0 .
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 point :) )

Posted: Wed Feb 01, 2006 7:02 am
by redmonkey
timvw wrote:(you are mistaken) If one bit is the sign then you end up with -0 and +0
No, you are mistaken, what (I think) you are precieving to be a bit representation of -0 is (in the case of a 32bit signed integer) a bit representation of -2,147,483,648.

Posted: Wed Feb 01, 2006 8:21 am
by pilau
redmonkey wrote:No, you are mistaken, what (I think) you are precieving to be a bit representation of -0 is (in the case of a 32bit signed integer) a bit representation of -2,147,483,648.
It is logical. Either way there's still much room to add another permission or two, which is great :)