@@ 1487-1501 (lines=15) @@ | ||
1484 | * If places is negative, HEX2BIN returns the #NUM! error value. |
|
1485 | * @return string |
|
1486 | */ |
|
1487 | public static function HEXTOBIN($x, $places = null) |
|
1488 | { |
|
1489 | $x = Functions::flattenSingleValue($x); |
|
1490 | $places = Functions::flattenSingleValue($places); |
|
1491 | ||
1492 | if (is_bool($x)) { |
|
1493 | return Functions::VALUE(); |
|
1494 | } |
|
1495 | $x = (string)$x; |
|
1496 | if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/', strtoupper($x), $out)) { |
|
1497 | return Functions::NAN(); |
|
1498 | } |
|
1499 | ||
1500 | return self::DECTOBIN(self::HEXTODEC($x), $places); |
|
1501 | } |
|
1502 | ||
1503 | ||
1504 | /** |
|
@@ 1640-1654 (lines=15) @@ | ||
1637 | * value. |
|
1638 | * @return string |
|
1639 | */ |
|
1640 | public static function OCTTOBIN($x, $places = null) |
|
1641 | { |
|
1642 | $x = Functions::flattenSingleValue($x); |
|
1643 | $places = Functions::flattenSingleValue($places); |
|
1644 | ||
1645 | if (is_bool($x)) { |
|
1646 | return Functions::VALUE(); |
|
1647 | } |
|
1648 | $x = (string)$x; |
|
1649 | if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { |
|
1650 | return Functions::NAN(); |
|
1651 | } |
|
1652 | ||
1653 | return self::DECTOBIN(self::OCTTODEC($x), $places); |
|
1654 | } |
|
1655 | ||
1656 | ||
1657 | /** |
|
@@ 1729-1744 (lines=16) @@ | ||
1726 | * If places is negative, OCT2HEX returns the #NUM! error value. |
|
1727 | * @return string |
|
1728 | */ |
|
1729 | public static function OCTTOHEX($x, $places = null) |
|
1730 | { |
|
1731 | $x = Functions::flattenSingleValue($x); |
|
1732 | $places = Functions::flattenSingleValue($places); |
|
1733 | ||
1734 | if (is_bool($x)) { |
|
1735 | return Functions::VALUE(); |
|
1736 | } |
|
1737 | $x = (string)$x; |
|
1738 | if (preg_match_all('/[01234567]/', $x, $out) != strlen($x)) { |
|
1739 | return Functions::NAN(); |
|
1740 | } |
|
1741 | $hexVal = strtoupper(dechex(self::OCTTODEC($x))); |
|
1742 | ||
1743 | return self::nbrConversionFormat($hexVal, $places); |
|
1744 | } |
|
1745 | ||
1746 | ||
1747 | /** |