Resent, due to lack of feedback from my side ;)

Andi replied:
>>
Why is it more correct to convert it to min/max values? I can't think of a
case where this would make more sense to the developer.
Also, there is a reason for the cast to unsigned int if the value is bigger
that LONG_MAX.
<<

I think it makes sense. If a float is out-of-range, it can usually not be
mod'd by 2**32, due to the nature of floats. Therefore, the only consistent
way would be going to the nearest integer possible.

Okay, because on most systems floats happen to be more precise than int's,
you _can_ mod them by 2**32, but there is a quite significant possibility of
having rounding errors. You cannot do integer-precision with floats.

And it's inconsistent too, PHP int's are ranging from -2**31 to (2**31)-1,
there is no such thing as unsigned integers. So why convert the float 3e9 to
something way below zero?

Additionally, a notice is a good idea here, just like what happens on
division by zero: the most natural result is returned, and a notice is
issued.

--Jeroen

----- Original Message -----
From: "Jeroen van Wolffelaar" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 02, 2001 2:39 AM
Subject: [PATCH] Fix for inconsistent float->int converting


> When a too-large float is converted to integer, it happens in a quite
> random way. When float is out of range, PHP should stick to the min
> resp. max values of integer.
>
> This patch will achieve this, I tested it succesfully.
>
> --Jeroen
>
> Jeroen van Wolffelaar
> [EMAIL PROTECTED]
> http://www.A-Eskwadraat.nl/~jeroen
>

double.diff

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to