Re: PHP 4.0 Bug #2261 Updated: Binary operators fail on args > 2G
| From: | Andi Gutmans | Date: | Thu, 09 Sep 1999 20:36:47 +0000 |
| Subject: | Re: PHP 4.0 Bug #2261 Updated: Binary operators fail on args > 2G | ||
| References: | 1 2 | Groups: | php.dev php.version4 |
| Request: | Send a blank email to php-version4+get-4293@lists.php.net to get a copy of this message | ||
At 06:54 PM 9/9/99 +0200, Wessel Dankers wrote:
You have reached the limit of the long type on your architecture. If you want arbitrary math precision use the BC module which gives you access to such functions. I know this must be the problem. The problem lies in the way php handles overflows. Ideally, it should treat values >2G as unsigned integers, meaning that if I would print it at that stage, I would get a negative number. The advantage of this is that subsequent additions and subtractions works as expected. For example: i=1000000000; a=i+i+i; a-=i; a-=i; a-=i; would make a end at 0. The current solution, which works by setting i to MAXINT, does have its own virtues, but I'm not sure which I like best.Well we liked it because PHP automatically adjusts itself to give you the result as a float as the integer result would usually be quite useless.
Another approach would be to switch to 64 bit math altogether. MySQL already does this (and has proper support for unsigned integers). Compared to the usual overhead of scripted languages I think the performance would not suffer very much. Would it be hard to convince the compilation procedure of MySQL that it's working on a 64-bit architecture (even if it's not)?I think this sounds interesting. How would you suggest to do it? Andi --- Andi Gutmans <andi@zend.com> http://www.zend.com/