3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "int cast: ",-( (int)((2 ** 32) - 0xffffffff)); // -1 echo "int cast: ", (int)(0xffffffff - (2 ** 32)); // -1 printf("\nprintf: %d\n", -((int) (2 ** 32) - 0xffffffff)); // treat as a signed number -- first gets cast to an int? echo "hexdec: "; var_dump((int) hexdec("ffffffff")); printf("\nprintf max int in hex: %x\n",PHP_INT_MAX); echo 0x5,"\n"; echo ~0x5 + 1,"\n"; // transform to -5 $n = sprintf("0x%x", (pow(2,32) - 5) ); // get 2s complement var_dump($n); $i = intval($n + 0); // trick that doesn't work anymore with PHP 7 echo $i; var_dump($i); printf("%x",$i); // display binary as hex $r = 0xffffffff & 0xfffffffb; // anding to simplify var_dump($r); echo 0xfb - pow(2,8); // to detect value of hex printf("\n%x\n",(pow(2, 32) - 5)); echo (5 + 0xfffffffb) == pow(2,32)? 'true':'false'; // floats both echo "\n",0xfffffffb > 0x7fffffff? 'true':'false';

preferences:
34.23 ms | 408 KiB | 5 Q