19 return [floor($number / self::SPLIT_DIVISOR), fmod($number, self::SPLIT_DIVISOR)];
35 public static function BITAND($number1, $number2)
38 $number1 = self::validateBitwiseArgument($number1);
39 $number2 = self::validateBitwiseArgument($number2);
41 return $e->getMessage();
43 $split1 = self::splitNumber($number1);
44 $split2 = self::splitNumber($number2);
46 return self::SPLIT_DIVISOR * ($split1[0] & $split2[0]) + ($split1[1] & $split2[1]);
62 public static function BITOR($number1, $number2)
65 $number1 = self::validateBitwiseArgument($number1);
66 $number2 = self::validateBitwiseArgument($number2);
68 return $e->getMessage();
71 $split1 = self::splitNumber($number1);
72 $split2 = self::splitNumber($number2);
74 return self::SPLIT_DIVISOR * ($split1[0] | $split2[0]) + ($split1[1] | $split2[1]);
90 public static function BITXOR($number1, $number2)
93 $number1 = self::validateBitwiseArgument($number1);
94 $number2 = self::validateBitwiseArgument($number2);
96 return $e->getMessage();
99 $split1 = self::splitNumber($number1);
100 $split2 = self::splitNumber($number2);
102 return self::SPLIT_DIVISOR * ($split1[0] ^ $split2[0]) + ($split1[1] ^ $split2[1]);
121 $number = self::validateBitwiseArgument($number);
122 $shiftAmount = self::validateShiftAmount($shiftAmount);
124 return $e->getMessage();
127 $result = floor($number * (2 ** $shiftAmount));
151 $number = self::validateBitwiseArgument($number);
152 $shiftAmount = self::validateShiftAmount($shiftAmount);
154 return $e->getMessage();
157 $result = floor($number / (2 ** $shiftAmount));
174 self::nullFalseTrueToNumber($value);
176 if (is_numeric($value)) {
177 if ($value == floor($value)) {
178 if (($value > 2 ** 48 - 1) || ($value < 0)) {
182 return floor($value);
200 self::nullFalseTrueToNumber($value);
202 if (is_numeric($value)) {
203 if (abs($value) > 53) {
221 if ($number === null) {
223 } elseif (is_bool($number)) {
224 $number = (int) $number;
static BITAND($number1, $number2)
BITAND.
static validateBitwiseArgument($value)
Validate arguments passed to the bitwise functions.
static validateShiftAmount($value)
Validate arguments passed to the bitwise functions.
static BITLSHIFT($number, $shiftAmount)
BITLSHIFT.
static splitNumber($number)
Split a number into upper and lower portions for full 32-bit support.
static nullFalseTrueToNumber(&$number)
Many functions accept null/false/true argument treated as 0/0/1.
static BITXOR($number1, $number2)
BITXOR.
static BITOR($number1, $number2)
BITOR.
static BITRSHIFT($number, $shiftAmount)
BITRSHIFT.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.