@@ 1385-1409 (lines=25) @@ | ||
1382 | * |
|
1383 | * @return string |
|
1384 | */ |
|
1385 | public static function DECTOHEX($x, $places = null) |
|
1386 | { |
|
1387 | $x = Functions::flattenSingleValue($x); |
|
1388 | $places = Functions::flattenSingleValue($places); |
|
1389 | ||
1390 | if (is_bool($x)) { |
|
1391 | if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { |
|
1392 | $x = (int) $x; |
|
1393 | } else { |
|
1394 | return Functions::VALUE(); |
|
1395 | } |
|
1396 | } |
|
1397 | $x = (string) $x; |
|
1398 | if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { |
|
1399 | return Functions::VALUE(); |
|
1400 | } |
|
1401 | $x = (string) floor($x); |
|
1402 | $r = strtoupper(dechex($x)); |
|
1403 | if (strlen($r) == 8) { |
|
1404 | // Two's Complement |
|
1405 | $r = 'FF' . $r; |
|
1406 | } |
|
1407 | ||
1408 | return self::nbrConversionFormat($r, $places); |
|
1409 | } |
|
1410 | ||
1411 | /** |
|
1412 | * DECTOOCT. |
|
@@ 1440-1465 (lines=26) @@ | ||
1437 | * |
|
1438 | * @return string |
|
1439 | */ |
|
1440 | public static function DECTOOCT($x, $places = null) |
|
1441 | { |
|
1442 | $xorig = $x; |
|
1443 | $x = Functions::flattenSingleValue($x); |
|
1444 | $places = Functions::flattenSingleValue($places); |
|
1445 | ||
1446 | if (is_bool($x)) { |
|
1447 | if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { |
|
1448 | $x = (int) $x; |
|
1449 | } else { |
|
1450 | return Functions::VALUE(); |
|
1451 | } |
|
1452 | } |
|
1453 | $x = (string) $x; |
|
1454 | if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { |
|
1455 | return Functions::VALUE(); |
|
1456 | } |
|
1457 | $x = (string) floor($x); |
|
1458 | $r = decoct($x); |
|
1459 | if (strlen($r) == 11) { |
|
1460 | // Two's Complement |
|
1461 | $r = substr($r, -10); |
|
1462 | } |
|
1463 | ||
1464 | return self::nbrConversionFormat($r, $places); |
|
1465 | } |
|
1466 | ||
1467 | /** |
|
1468 | * HEXTOBIN. |