Home Menu

decbin

Decimal to binary

Syntax

decbin ( int $number ) : string

Parameters

number

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

<?

$number = 0;

$return = decbin($number);

echo $return;

?>
0

2

<?

$number = 1;

$return = decbin($number);

echo $return;

?>
1

3

<?

$number = 2;

$return = decbin($number);

echo $return;

?>
10

4

<?

$number = 9223372036854775806;

$return = decbin($number);

echo $return;

?>
111111111111111111111111111111111111111111111111111111111111110

5

<?

$number = 9223372036854775807;

$return = decbin($number);

echo $return;

?>
111111111111111111111111111111111111111111111111111111111111111

6

<?

$number1 = -9223372036854775808;
$number2 = 9223372036854775808;

$return1 = decbin($number1);
$return2 = decbin($number2);

echo $return1 . PHP_EOL;
echo $return2;

?>

			
			

		

7

<?

$number1 = -2;
$number2 = 18446744073709551614;

$return1 = decbin($number1);
$return2 = decbin($number2);

echo $return1 . PHP_EOL;
echo $return2;

?>

			
			

		

8

<?

$number1 = -1;
$number2 = 18446744073709551615;

$return1 = decbin($number1);
$return2 = decbin($number2);

echo $return1 . PHP_EOL;
echo $return2;

?>

			
			

		

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms