On 17 Jul 2014, at 04:23, Sara Golemon <poll...@php.net> wrote:

> Do we need a new operator for that?  It feels un-php to me, and the
> kind of problem bigint objects should be meant to solve.  On the other
> hand, having $a/$b != $a/$b (Off by more than 100 in this instance).
> But back on the first hand, that's consistent with other operations on
> large floats anyway.  PHP_INT_MAX + 1 != One more than PHP_INT_MAX,

Actually, my bigints RFC would retain the existing / behaviour (float result if 
non-zero remainder), so to avoid an unnecessary divisibility check or to 
deliberately ignore the remainder you’d need some sort of integer division 
operator there. On the other hand, that RFC would also see ext/gmp always 
available, I suppose. Of course this isn’t what ext/gmp does *now*, where it 
makes / be integer division (yuck). I think the / operator’s behaviour makes 
complete sense and Python 3 actually does exactly the same thing as PHP here, 
because what / does is the most intuitive thing.

I suppose a function alone might do, but it feels a bit lacking to me not to 
have an operator for this. I’d also argue it’s not really un-PHP to add this, 
we already have the mod (%) operator and the bitwise operators also operate 
only on integers. Furthermore division ignoring the remainder is actually a 
fairly common use case (time for example), so I think there should be some way 
to do that when you need it. I wonder if the intent there might be clearer, 
too, than using floor() or (int).

--
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