array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.decbin.php', 1 => 'decbin', ), 'up' => array ( 0 => 'ref.math.php', 1 => 'Math 関数', ), 'prev' => array ( 0 => 'function.cosh.php', 1 => 'cosh', ), 'next' => array ( 0 => 'function.dechex.php', 1 => 'dechex', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', '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 — 10 進数を 2 進数に変換する
num
変換したい 10 進数値。
正の num |
負の num |
戻り値 |
---|---|---|
0 | 0 | |
1 | 1 | |
2 | 10 | |
... normal progression ... | ||
2147483646 | 1111111111111111111111111111110 | |
2147483647 (符号付き integer の最大値) | 1111111111111111111111111111111 (1 が 31 個) | |
2147483648 | -2147483648 | 10000000000000000000000000000000 |
... normal progression ... | ||
4294967294 | -2 | 11111111111111111111111111111110 |
4294967295 (符号なし integer の最大値) | -1 | 11111111111111111111111111111111 (1 が 32 個) |
正の num |
負の num |
戻り値 |
---|---|---|
0 | 0 | |
1 | 1 | |
2 | 10 | |
... normal progression ... | ||
9223372036854775806 | 111111111111111111111111111111111111111111111111111111111111110 | |
9223372036854775807 (符号付き integer の最大値) | 111111111111111111111111111111111111111111111111111111111111111 (1 が 63 個) | |
-9223372036854775808 | 1000000000000000000000000000000000000000000000000000000000000000 | |
... normal progression ... | ||
-2 | 1111111111111111111111111111111111111111111111111111111111111110 | |
-1 | 1111111111111111111111111111111111111111111111111111111111111111 (1 が 64 個) |
num
を 2 進文字列で表した値を返します。
例1 decbin() の例
<?php
echo decbin(12) . "\n";
echo decbin(26);
?>
上の例の出力は以下となります。
1100 11010