男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站

bindec

(PHP 4, PHP 5, PHP 7, PHP 8)

bindec二進(jìn)制轉換為十進(jìn)制

說(shuō)明

bindec(string $binary_string): number

返回 binary_string 參數所表示的二進(jìn)制數的十進(jìn)制等價(jià)值。

bindec() 將一個(gè)二進(jìn)制數轉換成 integer,或者出于大小的需要,轉換為 float 類(lèi)型。

bindec() 將所有的 binary_string 值解釋為無(wú)符號整數。這是由于 bindec() 函數將其最高有效位視為數量級而非符號位。

參數

binary_string

要轉換的二進(jìn)制字符串

警告

參數必須為字符串。使用其他數據類(lèi)型會(huì )導致不可預知的結果。

返回值

binary_string 的十進(jìn)制數值

更新日志

版本 說(shuō)明
4.1.0 本函數如今可以轉換超過(guò)程序運行平臺中 integer 類(lèi)型最大值的數,此時(shí)其值會(huì )返回為 float 類(lèi)型。

范例

示例 #1 bindec() 例子

<?php
echo bindec('110011') . "\n";
echo 
bindec('000110011') . "\n";

echo 
bindec('111');
?>

以上例程會(huì )輸出:

51
51
7

示例 #2 bindec() 將輸入解讀為無(wú)符號整數

<?php
/*
 * The lesson from this example is in the output
 * rather than the PHP code itself.
 */

$magnitude_lower pow(2, (PHP_INT_SIZE 8) - 2);
p($magnitude_lower 1);
p($magnitude_lower'See the rollover?  Watch it next time around...');

p(PHP_INT_MAX'PHP_INT_MAX');
p(~PHP_INT_MAX'interpreted to be one more than PHP_INT_MAX');

if (
PHP_INT_SIZE == 4) {
    
$note 'interpreted to be the largest unsigned integer';
} else {
    
$note 'interpreted to be the largest unsigned integer
              (18446744073709551615) but skewed by float precision'
;
}
p(-1$note);


function 
p($input$note '') {
    echo 
"input:        $input\n";

    
$format '%0' . (PHP_INT_SIZE 8) . 'b';
    
$bin sprintf($format$input);
    echo 
"binary:       $bin\n";

    
ini_set('precision'20);  // For readability on 64 bit boxes.
    
$dec bindec($bin);
    echo 
'bindec():     ' $dec "\n";

    if (
$note) {
        echo 
"NOTE:         $note\n";
    }

    echo 
"\n";
}
?>

以上例程在 32 位機器上的輸出:

input:        1073741823
binary:       00111111111111111111111111111111
bindec():     1073741823

input:        1073741824
binary:       01000000000000000000000000000000
bindec():     1073741824
NOTE:         See the rollover?  Watch it next time around...

input:        2147483647
binary:       01111111111111111111111111111111
bindec():     2147483647
NOTE:         PHP_INT_MAX

input:        -2147483648
binary:       10000000000000000000000000000000
bindec():     2147483648
NOTE:         interpreted to be one more than PHP_INT_MAX

input:        -1
binary:       11111111111111111111111111111111
bindec():     4294967295
NOTE:         interpreted to be the largest unsigned integer

以上例程在 64 位機器上的輸出:

input:        4611686018427387903
binary:       0011111111111111111111111111111111111111111111111111111111111111
bindec():     4611686018427387903

input:        4611686018427387904
binary:       0100000000000000000000000000000000000000000000000000000000000000
bindec():     4611686018427387904
NOTE:         See the rollover?  Watch it next time around...

input:        9223372036854775807
binary:       0111111111111111111111111111111111111111111111111111111111111111
bindec():     9223372036854775807
NOTE:         PHP_INT_MAX

input:        -9223372036854775808
binary:       1000000000000000000000000000000000000000000000000000000000000000
bindec():     9223372036854775808
NOTE:         interpreted to be one more than PHP_INT_MAX

input:        -1
binary:       1111111111111111111111111111111111111111111111111111111111111111
bindec():     18446744073709551616
NOTE:         interpreted to be the largest unsigned integer
              (18446744073709551615) but skewed by float precision

參見(jiàn)

  • decbin() - 十進(jìn)制轉換為二進(jìn)制
  • octdec() - 八進(jìn)制轉換為十進(jìn)制
  • hexdec() - 十六進(jìn)制轉換為十進(jìn)制
  • base_convert() - 在任意進(jìn)制之間轉換數字

男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站