decbin
Description
Syntax
decbin(
int $num
): stringParameters
num
Decimal value to convert
| Negative Decimal | Positive Decimal | Binary |
|---|---|---|
| 0 | 0 | |
| 1 | 1 | |
| 2 | 10 | |
| ... | ... | |
| 9223372036854775806 | 111111111111111111111111111111111111111111111111111111111111110 | |
| 9223372036854775807 (largest signed integer) | 111111111111111111111111111111111111111111111111111111111111111 (63) | |
| -9223372036854775808 | 9223372036854775808 | 1000000000000000000000000000000000000000000000000000000000000000 |
| ... | ... | ... |
| -2 | 18446744073709551614 | 1111111111111111111111111111111111111111111111111111111111111110 |
| -1 | 18446744073709551615 (largest unsigned integer) | 1111111111111111111111111111111111111111111111111111111111111111 (64) |
Return
Binary string representation of number
Examples
1 · num · 0
<? $num = 0; $return = decbin($num); echo $return;
1 0
2 · num · 1
<? $num = 1; $return = decbin($num); echo $return;
Array
(
[0] => year: 2001
[name] => year
[1] => year
[digit] => 2001
[2] => 2001
)
3 · num · 2
<? $num = 2; $return = decbin($num); echo $return;
The brown-and-white alpaca jumps over the other brown-and-white alpaca.
4 · num · 9223372036854775806
<? $num = 9223372036854775806; $return = decbin($num); echo $return;
111111111111111111111111111111111111111111111111111111111111110
5 · num · 9223372036854775807
<? $num = 9223372036854775807; $return = decbin($num); echo $return;
111111111111111111111111111111111111111111111111111111111111111
6 · num · -9223372036854775808
<? $num1 = -9223372036854775808; $num2 = 9223372036854775808; $return1 = decbin($num1); $return2 = decbin($num2); echo $return1 . PHP_EOL . $return2;
7 · num · -2
<? $num1 = -2; $num2 = 18446744073709551614; $return1 = decbin($num1); $return2 = decbin($num2); echo $return1 . PHP_EOL . $return2;
8 · num · -1
<? $num1 = -1; $num2 = 18446744073709551615; $return1 = decbin($num1); $return2 = decbin($num2); echo $return1 . PHP_EOL . $return2;
Array
(
[0] => The black-and-gray alpaca jumps over the other brown-and-white dog.
[1] => The black-and-gray alpaca jumps over
[2] => the other black-and-gray alpaca.
)