@@ 1369-1393 (lines=25) @@ | ||
1366 | * |
|
1367 | * @return string |
|
1368 | */ |
|
1369 | public static function DECTOHEX($x, $places = null) |
|
1370 | { |
|
1371 | $x = Functions::flattenSingleValue($x); |
|
1372 | $places = Functions::flattenSingleValue($places); |
|
1373 | ||
1374 | if (is_bool($x)) { |
|
1375 | if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { |
|
1376 | $x = (int) $x; |
|
1377 | } else { |
|
1378 | return Functions::VALUE(); |
|
1379 | } |
|
1380 | } |
|
1381 | $x = (string) $x; |
|
1382 | if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { |
|
1383 | return Functions::VALUE(); |
|
1384 | } |
|
1385 | $x = (string) floor($x); |
|
1386 | $r = strtoupper(dechex($x)); |
|
1387 | if (strlen($r) == 8) { |
|
1388 | // Two's Complement |
|
1389 | $r = 'FF' . $r; |
|
1390 | } |
|
1391 | ||
1392 | return self::nbrConversionFormat($r, $places); |
|
1393 | } |
|
1394 | ||
1395 | /** |
|
1396 | * DECTOOCT. |
|
@@ 1424-1449 (lines=26) @@ | ||
1421 | * |
|
1422 | * @return string |
|
1423 | */ |
|
1424 | public static function DECTOOCT($x, $places = null) |
|
1425 | { |
|
1426 | $xorig = $x; |
|
1427 | $x = Functions::flattenSingleValue($x); |
|
1428 | $places = Functions::flattenSingleValue($places); |
|
1429 | ||
1430 | if (is_bool($x)) { |
|
1431 | if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) { |
|
1432 | $x = (int) $x; |
|
1433 | } else { |
|
1434 | return Functions::VALUE(); |
|
1435 | } |
|
1436 | } |
|
1437 | $x = (string) $x; |
|
1438 | if (strlen($x) > preg_match_all('/[-0123456789.]/', $x, $out)) { |
|
1439 | return Functions::VALUE(); |
|
1440 | } |
|
1441 | $x = (string) floor($x); |
|
1442 | $r = decoct($x); |
|
1443 | if (strlen($r) == 11) { |
|
1444 | // Two's Complement |
|
1445 | $r = substr($r, -10); |
|
1446 | } |
|
1447 | ||
1448 | return self::nbrConversionFormat($r, $places); |
|
1449 | } |
|
1450 | ||
1451 | /** |
|
1452 | * HEXTOBIN. |