* Fix bug where values of 0 were "rounded" up/down as if they were not 0
This commit is contained in:
parent
9289ab11b2
commit
1f2f2c79da
|
@ -82,6 +82,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- PrintArea causes exception [#1544](https://github.com/phpoffice/phpspreadsheet/pull/1544)
|
- PrintArea causes exception [#1544](https://github.com/phpoffice/phpspreadsheet/pull/1544)
|
||||||
|
- ROUNDUP and ROUNDDOWN return incorrect results for values of 0 [#1627](https://github.com/phpoffice/phpspreadsheet/pull/1627)
|
||||||
- Calculation/DateTime Failure With PHP8 [#1661](https://github.com/phpoffice/phpspreadsheet/pull/1661)
|
- Calculation/DateTime Failure With PHP8 [#1661](https://github.com/phpoffice/phpspreadsheet/pull/1661)
|
||||||
- Reader/Gnumeric Failure with PHP8 [#1662](https://github.com/phpoffice/phpspreadsheet/pull/1662)
|
- Reader/Gnumeric Failure with PHP8 [#1662](https://github.com/phpoffice/phpspreadsheet/pull/1662)
|
||||||
- ReverseSort bug, exposed but not caused by PHP8 [#1660](https://github.com/phpoffice/phpspreadsheet/pull/1660)
|
- ReverseSort bug, exposed but not caused by PHP8 [#1660](https://github.com/phpoffice/phpspreadsheet/pull/1660)
|
||||||
|
|
|
@ -1108,6 +1108,10 @@ class MathTrig
|
||||||
$digits = Functions::flattenSingleValue($digits);
|
$digits = Functions::flattenSingleValue($digits);
|
||||||
|
|
||||||
if ((is_numeric($number)) && (is_numeric($digits))) {
|
if ((is_numeric($number)) && (is_numeric($digits))) {
|
||||||
|
if ($number == 0.0) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($number < 0.0) {
|
if ($number < 0.0) {
|
||||||
return round($number - 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_DOWN);
|
return round($number - 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_DOWN);
|
||||||
}
|
}
|
||||||
|
@ -1134,6 +1138,10 @@ class MathTrig
|
||||||
$digits = Functions::flattenSingleValue($digits);
|
$digits = Functions::flattenSingleValue($digits);
|
||||||
|
|
||||||
if ((is_numeric($number)) && (is_numeric($digits))) {
|
if ((is_numeric($number)) && (is_numeric($digits))) {
|
||||||
|
if ($number == 0.0) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($number < 0.0) {
|
if ($number < 0.0) {
|
||||||
return round($number + 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_UP);
|
return round($number + 0.5 * 0.1 ** $digits, $digits, PHP_ROUND_HALF_UP);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
662,
|
662,
|
||||||
662.78999999999996,
|
662.78999999999996,
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
],
|
||||||
[
|
[
|
||||||
663,
|
663,
|
||||||
662.78999999999996,
|
662.78999999999996,
|
||||||
|
|
Loading…
Reference in New Issue