Hi,

> On 3 Apr 2015, at 21:34, Dmitry Stogov <dmi...@zend.com> wrote:
> 
> 3) One more problem is modulo :(
> 
> $ sapi/cli/php -n -r "var_dump(1 % 0);"
> 
> Warning: Division by zero in Command line code on line 1
> bool(false)

Hmm, modulo is a more difficult one. Since it’s an integer-only operation in 
PHP, producing INF doesn’t make sense. It also doesn’t make sense 
mathematically. I think the most sensible thing to do here would be to throw an 
exception.

On the same note, the new function intdiv() is the counterpart to % for 
obtaining the quotient (% produces the remainder). It currently does the same 
thing as % and / division and produces FALSE with a warning. If % is changed, 
intdiv() should be too, because they are the same operation, just returning 
different parts of the result. An exception being produced by both would seem 
reasonable.

Thanks.

--
Andrea Faulds
http://ajf.me/





--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to