array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'function.decbin.php', 1 => 'decbin', ), 'up' => array ( 0 => 'ref.math.php', 1 => 'Fonctions Math', ), 'prev' => array ( 0 => 'function.cosh.php', 1 => 'cosh', ), 'next' => array ( 0 => 'function.dechex.php', 1 => 'dechex', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'fr', 'path' => 'reference/math/functions/decbin.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
decbin — Convertit de décimal en binaire
Retourne une chaîne contenant la représentation binaire de
l'entier num
donné en argument.
num
Valeur décimale à convertir
Paramètre num positif |
Paramètre num négatif |
Valeur retournée |
---|---|---|
0 | 0 | |
1 | 1 | |
2 | 10 | |
... progression normale ... | ||
2147483646 | 1111111111111111111111111111110 | |
2147483647 (plus grand entier signé) | 1111111111111111111111111111111 (31 uns) | |
2147483648 | -2147483648 | 10000000000000000000000000000000 |
... progression normale ... | ||
4294967294 | -2 | 11111111111111111111111111111110 |
4294967295 (plus grand entier non-signé) | -1 | 11111111111111111111111111111111 (32 uns) |
Paramètre num positif |
Paramètre num négatif |
Valeur retournée |
---|---|---|
0 | 0 | |
1 | 1 | |
2 | 10 | |
... progression normale ... | ||
9223372036854775806 | 111111111111111111111111111111111111111111111111111111111111110 | |
9223372036854775807 (plus grand entier signé) | 111111111111111111111111111111111111111111111111111111111111111 (63 uns) | |
-9223372036854775808 | 1000000000000000000000000000000000000000000000000000000000000000 | |
... progression normale ... | ||
-2 | 1111111111111111111111111111111111111111111111111111111111111110 | |
-1 | 1111111111111111111111111111111111111111111111111111111111111111 (64 uns) |
Une représentation binaire de num
.
Exemple #1 Exemple avec decbin()
<?php
echo decbin(12) . "\n";
echo decbin(26);
?>
L'exemple ci-dessus va afficher :
1100 11010
%b
,
%032b
ou %064b
comme format
%b
,
%032b
ou %064b
comme format