From 8080a297b785dcdbe9a6732db9cb176661847718 Mon Sep 17 00:00:00 2001 From: Ikko Ashimine Date: Sun, 17 Nov 2019 14:12:39 +0900 Subject: [PATCH 1/2] adjust to excel floor func behavior --- src/PhpSpreadsheet/Calculation/MathTrig.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 30071c2d02..fc9211b868 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -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; } From 6760e96eaa3db4525ac33c2181675129f125d251 Mon Sep 17 00:00:00 2001 From: Ikko Ashimine Date: Mon, 18 Nov 2019 20:26:50 +0900 Subject: [PATCH 2/2] fix FLOOR test case --- tests/data/Calculation/MathTrig/FLOOR.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/Calculation/MathTrig/FLOOR.php b/tests/data/Calculation/MathTrig/FLOOR.php index 4b2bd4a276..7d408173db 100644 --- a/tests/data/Calculation/MathTrig/FLOOR.php +++ b/tests/data/Calculation/MathTrig/FLOOR.php @@ -12,7 +12,7 @@ -2, ], [ - '#NUM!', + -4, -2.5, 2, ],