Warn when number base conversion loses precision - #22371
Conversation
|
@mvorisek Could you perhaps review this please? |
|
@LamentXU123 could you perhaps review this? |
| num = num * base + c; | ||
| break; | ||
| } else { | ||
| zend_error(E_NOTICE, "Input number exceeds maximum integer value, precision has been lost in conversion"); |
There was a problem hiding this comment.
I would prefer to indicate the actual "maximum integer value" the input exceed which will start to cause precision lost. But I am not the code owner tho, what do you all think? cc @arnaud-lb
There was a problem hiding this comment.
We could say something like "Input number is larger than PHP_INT_MAX, precision has been lost in conversion"
There was a problem hiding this comment.
Thanks, I changed it. I tried to think of something better but eventually just used what you suggested.
arnaud-lb
left a comment
There was a problem hiding this comment.
Looks good to me, thank you for this!
_php_math_basetozval is used for base_convert, bindec, hexdec and octdec. It uses an integer or double for the internal representation of the number. When the input number is too large to fit in there, it loses precision. This commit emits a notice when this happens. Discussion thread: https://news-web.php.net/php.internals/131364 PR: php#22371
4f4162d to
4575883
Compare
_php_math_basetozval is used for base_convert, bindec, hexdec and octdec. It uses an integer or double for the internal representation of the number. When the input number is too large to fit in there, it loses precision. This commit emits a notice when this happens. Discussion thread: https://news-web.php.net/php.internals/131364 PR: php#22371
4575883 to
e596757
Compare
_php_math_basetozval is used for base_convert, bindec, hexdec and octdec. It uses an integer or double for the internal representation of the number. When the input number is too large to fit in there, it loses precision. This commit emits a notice when this happens. Discussion thread: https://news-web.php.net/php.internals/131364 PR: php#22371
e596757 to
5df71d9
Compare
|
Thank you! |
|
@Sjord Nits: since people (including me) constantly forget to add the prefix in commits when merging, it will be great if you can add these in your PR title in the future. e.g. |
_php_math_basetozval is used for base_convert, bindec, hexdec and octdec. It uses an integer or double for the internal representation of the number. When the input number is too large to fit in there, it loses precision. This commit emits a notice when this happens.
Discussion thread: https://news-web.php.net/php.internals/131364