41    public static function toBinary($value, $places = 
null): string
 
   48            return $e->getMessage();
 
   76            return $e->getMessage();
 
   80        foreach (str_split($value) as $char) {
 
   81            $binX .= str_pad(decbin((
int) $char), 3, 
'0', STR_PAD_LEFT);
 
   83        if (strlen($binX) == 30 && $binX[0] == 
'1') {
 
   84            for (
$i = 0; 
$i < 30; ++
$i) {
 
   85                $binX[
$i] = ($binX[
$i] == 
'1' ? 
'0' : 
'1');
 
   88            return (
string) ((bindec($binX) + 1) * -1);
 
   91        return (
string) bindec($binX);
 
  120    public static function toHex($value, $places = 
null): string
 
  127            return $e->getMessage();
 
  130        $hexVal = strtoupper(dechex((
int) self::toDecimal($value)));
 
  131        $hexVal = (PHP_INT_SIZE === 4 && strlen($value) === 10 && $value[0] >= 
'4') ? 
"FF$hexVal" : $hexVal;
 
  138        $numDigits = (int) preg_match_all(
'/[01234567]/', $value);
 
  139        if (strlen($value) > $numDigits || $numDigits > 10) {
 
An exception for terminatinating execution or to throw for unit testing.
static nbrConversionFormat(string $value, ?int $places)
Formats a number base string value with leading zeroes.
static validatePlaces($places=null)
static validateValue($value)
static toBinary($value, $places=null)
toBinary.
static validateOctal(string $value)
static toBinary($value, $places=null)
toBinary.
static toDecimal($value)
toDecimal.
static toHex($value, $places=null)
toHex.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.