diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index 57116f28f5..319a2ed684 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -377,7 +377,7 @@ public static function BINTODEC($x) } } if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { - $x = floor($x); + $x = floor((float) $x); } $x = (string) $x; if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { @@ -432,7 +432,7 @@ public static function BINTOHEX($x, $places = null) } } if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { - $x = floor($x); + $x = floor((float) $x); } $x = (string) $x; if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { @@ -442,9 +442,9 @@ public static function BINTOHEX($x, $places = null) return Functions::NAN(); } elseif (strlen($x) == 10) { // Two's Complement - return str_repeat('F', 8) . substr(strtoupper(dechex(bindec(substr($x, -9)))), -2); + return str_repeat('F', 8) . substr(strtoupper(dechex((int) bindec(substr($x, -9)))), -2); } - $hexVal = (string) strtoupper(dechex(bindec($x))); + $hexVal = (string) strtoupper(dechex((int) bindec($x))); return self::nbrConversionFormat($hexVal, $places); } @@ -485,7 +485,7 @@ public static function BINTOOCT($x, $places = null) } } if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) { - $x = floor($x); + $x = floor((float) $x); } $x = (string) $x; if (strlen($x) > preg_match_all('/[01]/', $x, $out)) { @@ -495,9 +495,9 @@ public static function BINTOOCT($x, $places = null) return Functions::NAN(); } elseif (strlen($x) == 10) { // Two's Complement - return str_repeat('7', 7) . substr(strtoupper(decoct(bindec(substr($x, -9)))), -3); + return str_repeat('7', 7) . substr(strtoupper(decoct((int) bindec(substr($x, -9)))), -3); } - $octVal = (string) decoct(bindec($x)); + $octVal = (string) decoct((int) bindec($x)); return self::nbrConversionFormat($octVal, $places); } @@ -546,7 +546,7 @@ public static function DECTOBIN($x, $places = null) return Functions::VALUE(); } - $x = (string) floor($x); + $x = (int) floor((float) $x); if ($x < -512 || $x > 511) { return Functions::NAN(); } @@ -604,7 +604,7 @@ public static function DECTOHEX($x, $places = null) if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { return Functions::VALUE(); } - $x = (string) floor($x); + $x = (int) floor((float) $x); $r = strtoupper(dechex($x)); if (strlen($r) == 8) { // Two's Complement @@ -658,7 +658,7 @@ public static function DECTOOCT($x, $places = null) if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { return Functions::VALUE(); } - $x = (string) floor($x); + $x = (int) floor((float) $x); $r = decoct($x); if (strlen($r) == 11) { // Two's Complement @@ -945,7 +945,7 @@ public static function OCTTOHEX($x, $places = null) if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { return Functions::NAN(); } - $hexVal = strtoupper(dechex(self::OCTTODEC($x))); + $hexVal = strtoupper(dechex((int) self::OCTTODEC((int) $x))); return self::nbrConversionFormat($hexVal, $places); }