[PHP-DEV] Re: PHP 4.0 Bug #2261 Updated: Binary operators fail on args > 2G From: Andi Gutmans (andi <email protected>)
Date: 09/09/99

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 <email protected>>
http://www.zend.com/

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>