View Single Post
Old 2014-02-13, 23:57   #4
daxmick
 
daxmick's Avatar
 
Feb 2014

22×3×7 Posts
Default

Quote:
Originally Posted by potonono View Post
See the following page under section "Example #3 Integer overflow on a 32-bit system".

http://us3.php.net/manual/en/language.types.integer.php

That number is treated as a float, not an integer.
Thanks for the info! Going with this idea I change my "while(1)" to while(is_resource($NumberToTest))" and then added a bit of code at the bottom of my script to print out what $NumberToTest is (I should only ever drop out of the while loop if $NumberToTest is no longer a gmp resource). And indeed I did get dropped out of the while loop and $NumberToTest prints out as "Resource id #-2147483648".

The odd thing is that the only time I modify the $NumberToTest variable is at the end of the loop when I add 2 to it (to get the next odd number) and I haven't even come close to exceeding 2^32 sized number (I'm only in the 550*10^6 range).

So, what do you think this could be???

EDIT: I added a print of $NumberToTest to print out not as a string but as a raw Resource variable every 12345 loops and I find something interesting!
Quote:
2014-02-13 16:59:06 --> NumberToTest = 543804595
NumberToTest as a Resource: Resource id #13912458
2014-02-13 17:00:26 --> NumberToTest = 543913237
NumberToTest as a Resource: Resource id #28141589
2014-02-13 17:01:49 --> NumberToTest = 544021879
NumberToTest as a Resource: Resource id #42184263
Maybe there is a bug in the PHP GMP process that accidentally assigns an out of range value on occasion? Maybe I have a 64 bit GMP library but only a 32 bit PHP process?

Last fiddled with by daxmick on 2014-02-14 at 00:04
daxmick is offline   Reply With Quote