Skip to content

Commit

Permalink
Bugfix: Work Item PHPOfficeGH-302 - Fix for CEIL() and FLOOR() when n…
Browse files Browse the repository at this point in the history
…umber argument is zero
  • Loading branch information
MarkBaker committed Dec 6, 2014
1 parent 741500d commit 4d67ff7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Classes/PHPExcel/Calculation/MathTrig.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public static function CEILING($number, $significance = NULL) {
$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;
Expand Down Expand Up @@ -316,10 +316,9 @@ public static function FLOOR($number, $significance = NULL) {
}

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();
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d67ff7

Please sign in to comment.