On 29.12.2017 at 16:37, Nikita Popov wrote:

> On Fri, Dec 29, 2017 at 1:08 PM, Fleshgrinder <p...@fleshgrinder.com> wrote:
> 
>> What is the use case for `int|float`? I mean, if f is able to process a
>> `float` than f is able to process an `int` and since `int` is already
>> automatically changed to a `float`, well, you're done.
> 
> int|float is the natural type of numeric operations in PHP. Integers
> automatically overflow into floating point numbers, so signatures using int
> in conjunction with numeric operations are somewhat problematic.

In my humble opinion, introducing `int|float` or `number` types would
not solve the real problem, namely that overflowing to float easily
causes unexpected behavior.  For instance:

  PHP_INT_MAX + 1 > PHP_INT_MAX // => false (64bit arch)

-- 
Christoph M. Becker

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

Reply via email to