Thread: int is useless
View Single Post
  #13  
Old 01-27-2009, 03:20 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Loriel View Post
Nice theory, except booth floor and intval get 262143/32768 right.
In PHP, maybe. We're talking about GS2 here, so we have to assume that it's going to screw up easily with large decimals, as seen when it can't correctly subtract 8 from 7.999969482. Obviously, it's rounding 7.999969482 to 8, which is also why int(7.999969482) returns 8 instead of 7.

I did a quick test on RC. int(7.999) returns 7, but int(7.9999) returns 8. int(7.9998) returns 7, as well as int(7.999899999). Considering that 7.9999 and 7.999969482 have one thing in common, it's safe to assume that when Graal sees ".9999", it'll round up to the nearest whole number.

Quote:
Originally Posted by Tyhm View Post
I'd love to, but it's difficult to determine if the bitflag 262143 contains 32768 (2^15th) or not without doing a little division.
What are you trying to accomplish, exactly? Perhaps if you showed us the problem in context, somebody might be able to figure something out (unless you're fine with using your work-around).
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote