Skip to content

Commit

Permalink
FLOOR() function accept negative number and negative significance
Browse files Browse the repository at this point in the history
Closes #1245
  • Loading branch information
eltociear authored and PowerKiKi committed Nov 30, 2019
1 parent 9fa45f7 commit cc92c66
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).

### Fixed

- ...
- FLOOR() function accept negative number and negative significance [#1245](https://github.com/PHPOffice/PhpSpreadsheet/pull/1245)

## [1.10.0] - 2019-11-18

Expand Down
4 changes: 3 additions & 1 deletion src/PhpSpreadsheet/Calculation/MathTrig.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ public static function FLOOR($number, $significance = null)
return Functions::DIV0();
} elseif ($number == 0.0) {
return 0.0;
} elseif (self::SIGN($number) == self::SIGN($significance)) {
} elseif (self::SIGN($significance) == 1) {
return floor($number / $significance) * $significance;
} elseif (self::SIGN($number) == -1 && self::SIGN($significance) == -1) {
return floor($number / $significance) * $significance;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/data/Calculation/MathTrig/FLOOR.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-2,
],
[
'#NUM!',
-4,
-2.5,
2,
],
Expand Down

0 comments on commit cc92c66

Please sign in to comment.