Re: NAN and INF cast to int
| From: | Julien Pauli | Date: | Mon, 06 Jan 2014 12:52:33 +0000 |
| Subject: | Re: NAN and INF cast to int | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-71015@lists.php.net to get a copy of this message | ||
On Thu, Jan 2, 2014 at 8:31 PM, Andrea Faulds <ajf@ajf.me> wrote:
>
>
> On 02/01/14 19:08, Robert Stoll wrote:
>>
>>
>>
>> And the other part about division by 0 yields false. I rethought it and
>> conclude that it makes somewhat sense for a
>> purely int division. However, it does not make sense for a floating point
>> number division IMO and should be NAN or INF
>> instead as suggested by IEEE 754.
>> Yet, since this would be a BC break I understand that it cannot be changed
>> in 5.x but maybe in PHP 6?
>>
>
> Hey, why not make div-by-0 with ints also yield Infinity? It's a nicer and
> more practical approach than throwing a warning, IMO, because you don't have
> to check for zero at every single division, you'll just get an eventual
> output which tells you something went wrong.
I'm +1 to make div by zero return INF.
I'm also +1 for every math "strange" operation to issue a warning,
like div by zero, or else.
Julien