function Calculator::toBinary
Converts a decimal number to a binary string.
Parameters
string $number The number to convert, positive or zero, only digits.:
1 call to Calculator::toBinary()
- Calculator::bitwise in vendor/
brick/ math/ src/ Internal/ Calculator.php - Performs a bitwise operation on a decimal number.
File
-
vendor/
brick/ math/ src/ Internal/ Calculator.php, line 629
Class
- Calculator
- Performs basic operations on arbitrary size integers.
Namespace
Brick\Math\InternalCode
private function toBinary(string $number) : string {
$result = '';
while ($number !== '0') {
[
$number,
$remainder,
] = $this->divQR($number, '256');
$result .= \chr((int) $remainder);
}
return \strrev($result);
}