decbin

(PHP 4, PHP 5, PHP 7)

decbin十锟斤拷锟斤拷转锟斤拷为锟斤拷锟斤拷锟斤拷

说锟斤拷

decbin ( int $number ) : string

锟斤拷锟斤拷一锟街凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟叫革拷锟斤拷 number 锟斤拷锟斤拷锟侥讹拷锟斤拷锟狡憋拷示锟斤拷锟斤拷锟斤拷转锟斤拷锟斤拷锟斤拷锟斤拷锟街滴拷锟斤拷频锟� 4294967295锟斤拷锟斤拷锟斤拷为 32 锟斤拷 1 锟斤拷锟街凤拷锟斤拷锟斤拷

锟斤拷锟斤拷

number

Decimal value to convert

Range of inputs on 32-bit machines
positive number negative number return value
0   0
1   1
2   10
... normal progression ...
2147483646   1111111111111111111111111111110
2147483647 (largest signed integer)   1111111111111111111111111111111 (31 1's)
2147483648 -2147483648 10000000000000000000000000000000
... normal progression ...
4294967294 -2 11111111111111111111111111111110
4294967295 (largest unsigned integer) -1 11111111111111111111111111111111 (32 1's)
Range of inputs on 64-bit machines
positive number negative number return value
0   0
1   1
2   10
... normal progression ...
9223372036854775806   111111111111111111111111111111111111111111111111111111111111110
9223372036854775807 (largest signed integer)   111111111111111111111111111111111111111111111111111111111111111 (63 1's)
  -9223372036854775808 1000000000000000000000000000000000000000000000000000000000000000
... normal progression ...
  -2 1111111111111111111111111111111111111111111111111111111111111110
  -1 1111111111111111111111111111111111111111111111111111111111111111 (64 1's)

锟斤拷锟斤拷值

Binary string representation of number

锟斤拷锟斤拷

Example #1 decbin() 锟斤拷锟斤拷

<?php
echo decbin(12) . "\n";
echo 
decbin(26);
?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

1100
11010

锟轿硷拷

  • bindec() - 锟斤拷锟斤拷锟斤拷转锟斤拷为十锟斤拷锟斤拷
  • decoct() - 十锟斤拷锟斤拷转锟斤拷为锟剿斤拷锟斤拷
  • dechex() - 十锟斤拷锟斤拷转锟斤拷为十锟斤拷锟斤拷锟斤拷
  • base_convert() - 锟斤拷锟斤拷锟斤拷锟斤拷锟街拷锟阶拷锟斤拷锟斤拷锟�
  • printf() - 锟斤拷锟斤拷锟绞斤拷锟斤拷址锟斤拷锟�, using %b, %032b or %064b as the format
  • sprintf(), using %b, %032b or %064b as the format