Re: double val to long val conversion issue

From: Date: Mon, 11 Feb 2013 21:57:23 +0000
Subject: Re: double val to long val conversion issue
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-65770@lists.php.net to get a copy of this message
On Mon, 11 Feb 2013 09:43:36 +0100, Remi Collet <remi@fedoraproject.org> wrote:
Le 10/02/2013 20:27, Gustavo Lopes a écrit :
Any reservations?
For which values ? Outside LONG_MIN .. ULONG_MAX ?
It should be valid for the whole domain, but for performance reasons it would be better to limit it to values at least outside the (LONG_MIN, LONG_MAX) interval. Testing also against LONG_MIN has a measurable performance hit in my tests (+40%), but that should not matter (on my old laptop, you can still run the inlined function 1e9 times per second for values in the long range, i.e., it takes around 1 ns).
Do we really want/need to change the current behavior. Cast from double, outside of integer range, result in a fix value. The only problem is that the value is not the same on all arch.
Sure, that is also an option, but since we already have a wrapping behavior in the LONG_MAX..ULONG_MAX range, it would make sense to keep a similar behavior throughout the double domain, I think. It would be inconsistent to have it wrap on LONG_MAX, but for values smaller than LONG_MIN or larger than ULONG_MAX give a fixed value. -- Gustavo Lopes

« previous php.internals (#65770) next »