3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* convert 64-bit numeric string to decimal */ function showDecimal( $bin, $base ) { if ($bin[0] == 'F' && $bin[1] == 'F'){ $bin = substr($bin,1); // trim string so may } $num = intval( $bin, $base ); // convert to binary number $num &= 0xffff; // using only rightmost 16 bits if ( 0x8000 & $num ) { // true if $num is negative ... $num =( $num - (2 ** 16) ); $num2 = -((2 ** 16) - 0xfffd); var_dump($num2); } return $num; } $c = "FFFFFFFFFFFFFFFD"; // TC in hexadecimal for: echo showDecimal($c,16),"\n"; // -3

preferences:
55.03 ms | 402 KiB | 5 Q