35 public static function toBinary($value, $places =
null): string
42 return $e->getMessage();
72 return $e->getMessage();
75 if (strlen($value) > 10) {
80 foreach (str_split($value) as $char) {
81 $binX .= str_pad(base_convert($char, 16, 2), 4,
'0', STR_PAD_LEFT);
83 if (strlen($binX) == 40 && $binX[0] ==
'1') {
84 for (
$i = 0;
$i < 40; ++
$i) {
85 $binX[
$i] = ($binX[
$i] ==
'1' ?
'0' :
'1');
88 return (
string) ((bindec($binX) + 1) * -1);
91 return (
string) bindec($binX);
123 public static function toOctal($value, $places =
null): string
130 return $e->getMessage();
140 if (strlen($value) > preg_match_all(
'/[0123456789ABCDEF]/', $value)) {
An exception for terminatinating execution or to throw for unit testing.
static validatePlaces($places=null)
static validateValue($value)
static toOctal($value, $places=null)
toOctal.
static toBinary($value, $places=null)
toBinary.
static toOctal($value, $places=null)
toOctal.
static validateHex(string $value)
static toBinary($value, $places=null)
toBinary.
static toDecimal($value)
toDecimal.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.