3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "int cast: ",(int)(0xffffffffffffffff & 0xffff); // -1 printf("\nprintf: %d\n",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';
Output for 8.5.0 - 8.5.1
int cast: Warning: The float 1.8446744073709552E+19 is not representable as an int, cast occurred in /in/8F6r8 on line 3 0 printf: 4294967295 hexdec: int(4294967295) printf max int in hex: 7fffffffffffffff 5 -5 string(10) "0xfffffffb" Warning: A non-numeric value encountered in /in/8F6r8 on line 13 0int(0) 0int(4294967291) -5 fffffffb true true
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.4.16
int cast: Deprecated: Implicit conversion from float 1.8446744073709552E+19 to int loses precision in /in/8F6r8 on line 3 0 printf: 4294967295 hexdec: int(4294967295) printf max int in hex: 7fffffffffffffff 5 -5 string(10) "0xfffffffb" Warning: A non-numeric value encountered in /in/8F6r8 on line 13 0int(0) 0int(4294967291) -5 fffffffb true true
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.0.0 - 8.0.30
int cast: 0 printf: 4294967295 hexdec: int(4294967295) printf max int in hex: 7fffffffffffffff 5 -5 string(10) "0xfffffffb" Warning: A non-numeric value encountered in /in/8F6r8 on line 13 0int(0) 0int(4294967291) -5 fffffffb true true
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
int cast: 0 printf: 4294967295 hexdec: int(4294967295) printf max int in hex: 7fffffffffffffff 5 -5 string(10) "0xfffffffb" Notice: A non well formed numeric value encountered in /in/8F6r8 on line 13 0int(0) 0int(4294967291) -5 fffffffb true true
Output for 7.0.0 - 7.0.20, 7.3.32 - 7.3.33
int cast: 0 printf: 4294967295 hexdec: int(4294967295) printf max int in hex: 7fffffffffffffff 5 -5 string(10) "0xfffffffb" 0int(0) 0int(4294967291) -5 fffffffb true true
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
int cast: 0 printf: 4294967295 hexdec: int(4294967295) printf max int in hex: 7fffffffffffffff 5 -5 string(10) "0xfffffffb" 4294967291int(4294967291) fffffffbint(4294967291) -5 fffffffb true true

preferences:
183.39 ms | 416 KiB | 5 Q