Re: [RFC] Big Integer Support

From: Date: Tue, 14 Oct 2014 21:48:24 +0000
Subject: Re: [RFC] Big Integer Support
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message

On 14 Oct 2014, at 21:47, Stas Malyshev <[email protected]> wrote:

>> You throw an error. Just as plenty of functions already can’t handle
>> ridiculously large integer arguments.
> 
> The problem is, if you function can handle the int range and you checked
> for is_int() and everything worked fine - now it's broken because
> is_int() no longer implies fixed range and there's no way to check if
> you're dealing with fixed-range number or infinite-range number.

Yes, but you *can* check if the function errors. I don’t really think this is a massive problem.
People will probably not realistically expect that all functions can accept really large numbers,
whether that range cuts off at 2**64-1 or something more arbitrary. It’s a problem if abs() or
sign() don’t work for bigints. It isn’t if str_repeat() doesn’t, because a similarly-sized
non-bigint would error too.

> 
>> No, it does: There are now integers, and objects that represent large
>> integers, which behave differently.
> 
> IS_INT and IS_BIGINT would necessarily behave differently too - since
> some functions may support both and some only integers.

All functions would “support” both for integer arguments. But some might choose to reject
bigints which are larger than the internal integer type the function uses… much like a function
written for PHP currently might reject longs larger than the internal integer type the function
uses.

> Again, no change
> here.

The point is the degree to which they can act the same. Objects can only go so far.
--
Andrea Faulds
http://ajf.me/






Thread (70 messages)

« previous php.internals (#78073) next »