From 4d67ff7de9e2109fb5dcf1dee9ad5348302558e3 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Sat, 6 Dec 2014 17:44:27 +0000 Subject: [PATCH] Bugfix: Work Item GH-302 - Fix for CEIL() and FLOOR() when number argument is zero --- Classes/PHPExcel/Calculation/MathTrig.php | 11 +++++------ changelog.txt | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Classes/PHPExcel/Calculation/MathTrig.php b/Classes/PHPExcel/Calculation/MathTrig.php index 9f0e7f4c..f3ae111e 100644 --- a/Classes/PHPExcel/Calculation/MathTrig.php +++ b/Classes/PHPExcel/Calculation/MathTrig.php @@ -145,8 +145,8 @@ class PHPExcel_Calculation_MathTrig { $significance = $number/abs($number); } - if ((is_numeric($number)) && (is_numeric($significance))) { - if ($significance == 0.0) { + if ((is_numeric($number)) && (is_numeric($significance))) { + if (($number == 0.0 ) || ($significance == 0.0)) { return 0.0; } elseif (self::SIGN($number) == self::SIGN($significance)) { return ceil($number / $significance) * $significance; @@ -316,10 +316,9 @@ class PHPExcel_Calculation_MathTrig { } if ((is_numeric($number)) && (is_numeric($significance))) { - if ((float) $significance == 0.0) { - return PHPExcel_Calculation_Functions::DIV0(); - } - if (self::SIGN($number) == self::SIGN($significance)) { + if (($number == 0.0 ) || ($significance == 0.0)) { + return 0.0; + } elseif (self::SIGN($number) == self::SIGN($significance)) { return floor($number / $significance) * $significance; } else { return PHPExcel_Calculation_Functions::NaN(); diff --git a/changelog.txt b/changelog.txt index 6a5bb81c..0b8845f1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -37,6 +37,7 @@ Planned for v1.8.1 - Bugfix: (frozenstupidity) Work Item GH-423 - Fix invalid NA return in VLOOKUP - Bugfix: (wiseloren) Work Item CP21454 - "No Impact" conditional formatting fix for NumberFormat - Bugfix: (bobwitlox) Work Item GH-467 - Bug in Excel2003XML reader, parsing merged cells +- Bugfix: (MBaker) Work Item GH-302 - Fix for CEIL() and FLOOR() when number argument is zero - General: (MBaker) - Small performance improvement for autosize columns - General: (frost-nzcr4) Work Item GH-379 - Change the getter/setter for zeroHeight to camel case - General: (MBaker) Work Item GH-394 - DefaultValueBinder is too much aggressive when converting string to numeric