[php-src] PR #12162: Fix GH-12143: Improved handling of adjusting result digits
| From: | SakiTakamachi | Date: | Sat, 09 Sep 2023 15:23:20 +0000 |
| Subject: | [php-src] PR #12162: Fix GH-12143: Improved handling of adjusting result digits | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-23610@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/12162
Author: SakiTakamachi
This PR fixes https://github.com/php/php-src/issues/12143
Two types of problems were discovered in this issue, this will fix one of them.
During the "pre round" process that adjusts the number of digits of values greater
than
1e14 to 1e14, round() results may lead to incorrect
because rounding is done.
incorrect example:
```
<?php
var_dump(round(1.700000000000145, 13, PHP_ROUND_HALF_UP));
// float(1.7000000000002)
var_dump(round(-1.700000000000145, 13, PHP_ROUND_HALF_UP));
// float(-1.7000000000002)
```
If you want to figure out what's going on, this comment of @jorgsowa 's is easy to
understand.
https://github.com/php/php-src/issues/12143#issuecomment-1712261894