Introduce PHP_INT_MAX_SAFE constant similar to JS's Number.MAX_SAFE_INTEGER constant
| From: | Gina P. Banyard | Date: | Mon, 14 Jul 2025 11:54:57 +0000 |
| Subject: | Introduce PHP_INT_MAX_SAFE constant similar to JS's Number.MAX_SAFE_INTEGER constant | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-128032@lists.php.net to get a copy of this message | ||
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
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER