On 3 Aug 2014, at 15:27, Lester Caine <les...@lsces.co.uk> wrote:

> Your missing the point I was trying to make. That "(int)(3 / 2)"
> essentially goes wrong only on 64bit systems is the bug that needs
> fixing.

(int)(3 / 2) works fine, (int)(PHP_INT_MAX / 3) does not.

It’s not a bug, it’s entirely intentional and expected behaviour. You’re doing 
a floating-point division then casting to integer, which will sometimes lead to 
a loss of precision.

And no, having a division wrapped in (int) work differently from a normal 
division isn’t a good idea. That means the operator acts differently based on 
context. It would mean $a = PHP_INT_MAX / 3; $a = (int)$a; would do something 
entirely different from $a = (int)(PHP_INT_MAX / 3);

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