As another contender, how about:

$x = 242 %/ 7;
$x %/= 13;

The % reflects the relationship to modulus, while the / reflects the
division effect.  I think %/ looks worse, but I think it seems more apropos.
 On Jul 16, 2014 11:15 AM, "Andrea Faulds" <a...@ajf.me> wrote:


On 16 Jul 2014, at 02:51, Bishop Bettini <bis...@php.net> wrote:

> TL;DR -- I agree with the principal but want implemented as the infix
> operator %% with a test for PHP_INT_MIN %% -1 === false (and a E_WARNING).

The RFC has been updated to v0.2. It now proposes a %% operator for integer
division (with corresponding %%= assignment operator). However, it returns
0 for the PHP_INT_MIN overflow case like %, rather than FALSE and an
E_WARNING.

The original intdiv() proposal is kept as a fallback; two votes will be
held simultaneously, one 2/3 vote for the %% operator and a 50%+1 for the
intdiv() function. If the first fails, then if the second did not, the
intdiv() function is implemented instead. This way we’ll still at least
have a way to do integer division in PHP, if not a full operator.

Nikita Popov doesn’t seem to be a fan of the %% syntax, so it may be
subject to change, though I think it’s the best I’ve heard so far. ;)
--
Andrea Faulds
http://ajf.me/

Reply via email to