Hello internals,
I'm mailing the list for the bike shed of the naming of a new constant I think we should introduce in PHP which I'm currently calling PHP_INT_MAX_SAFE.
The purpose of this integer is to indicate what is the maximal integer value that can be correctly represented by a float.
On 32 bits this is equal to PHP_INT_MAX, but on 64 bits it is 9007199254740991 (which is 2^(53) – 1) as the mantissa of a floating point number is 52 bits.
For more information, please see the MDN documentation about Number.MAX_SAFE_INTEGER. [1]
The implementation is very simple and the PR is https://github.com/php/php-src/pull/19126
Best regards,
Gina P. Banyard
Hi
Am 2025-07-14 13:54, schrieb Gina P. Banyard:
The purpose of this integer is to indicate what is the maximal integer
value that can be correctly represented by a float.
On 32 bits this is equal to PHP_INT_MAX, but on 64 bits it is
9007199254740991 (which is 2^(53) – 1) as the mantissa of a floating
point number is 52 bits.
I don't understand why this should be equal to PHP_INT_MAX
for 32 Bit
builds. The largest integer that can be safely represented by a float is
2^53-1 for both 32 and 64 Bit builds of PHP. More generally, I do not
understand the value of the constant. PHP has proper integers, whereas
JavaScript does not.
Best regards
Tim Düsterhu