|
@@ 1488-1502 (lines=15) @@
|
| 1485 |
|
* If places is negative, HEX2OCT returns the #NUM! error value. |
| 1486 |
|
* @return string |
| 1487 |
|
*/ |
| 1488 |
|
public static function HEXTOOCT($x, $places=null) { |
| 1489 |
|
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
| 1490 |
|
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
| 1491 |
|
|
| 1492 |
|
if (is_bool($x)) { |
| 1493 |
|
return PHPExcel_Calculation_Functions::VALUE(); |
| 1494 |
|
} |
| 1495 |
|
$x = (string) $x; |
| 1496 |
|
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) { |
| 1497 |
|
return PHPExcel_Calculation_Functions::NaN(); |
| 1498 |
|
} |
| 1499 |
|
$octVal = decoct(hexdec($x)); |
| 1500 |
|
|
| 1501 |
|
return self::_nbrConversionFormat($octVal,$places); |
| 1502 |
|
} // function HEXTOOCT() |
| 1503 |
|
|
| 1504 |
|
|
| 1505 |
|
/** |
|
@@ 1539-1553 (lines=15) @@
|
| 1536 |
|
* value. |
| 1537 |
|
* @return string |
| 1538 |
|
*/ |
| 1539 |
|
public static function OCTTOBIN($x, $places=null) { |
| 1540 |
|
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
| 1541 |
|
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
| 1542 |
|
|
| 1543 |
|
if (is_bool($x)) { |
| 1544 |
|
return PHPExcel_Calculation_Functions::VALUE(); |
| 1545 |
|
} |
| 1546 |
|
$x = (string) $x; |
| 1547 |
|
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { |
| 1548 |
|
return PHPExcel_Calculation_Functions::NaN(); |
| 1549 |
|
} |
| 1550 |
|
$r = decbin(octdec($x)); |
| 1551 |
|
|
| 1552 |
|
return self::_nbrConversionFormat($r,$places); |
| 1553 |
|
} // function OCTTOBIN() |
| 1554 |
|
|
| 1555 |
|
|
| 1556 |
|
/** |
|
@@ 1618-1632 (lines=15) @@
|
| 1615 |
|
* If places is negative, OCT2HEX returns the #NUM! error value. |
| 1616 |
|
* @return string |
| 1617 |
|
*/ |
| 1618 |
|
public static function OCTTOHEX($x, $places=null) { |
| 1619 |
|
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x); |
| 1620 |
|
$places = PHPExcel_Calculation_Functions::flattenSingleValue($places); |
| 1621 |
|
|
| 1622 |
|
if (is_bool($x)) { |
| 1623 |
|
return PHPExcel_Calculation_Functions::VALUE(); |
| 1624 |
|
} |
| 1625 |
|
$x = (string) $x; |
| 1626 |
|
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) { |
| 1627 |
|
return PHPExcel_Calculation_Functions::NaN(); |
| 1628 |
|
} |
| 1629 |
|
$hexVal = strtoupper(dechex(octdec($x))); |
| 1630 |
|
|
| 1631 |
|
return self::_nbrConversionFormat($hexVal,$places); |
| 1632 |
|
} // function OCTTOHEX() |
| 1633 |
|
|
| 1634 |
|
|
| 1635 |
|
/** |