3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* convert 16-bit numeric string to decimal */ function showDecimal( $bin, $base ) { $num = intval( $bin, $base ); $num &= 0xffff; // using only last 16 bits if ( 0x8000 & $num ) { // true if $num is negative ... $num =( $num - 0x010000 ); } return $num; } $b = "ffffffbf"; // 2s complement (hex) for echo showDecimal($b,16),"\n"; // -65 $c = "1111111111111101"; // 2s complement (binary) for echo showDecimal($c,2),"\n"; // -3
Output for git.master, git.master_jit, rfc.property-hooks
-65 -3

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.49 ms | 401 KiB | 8 Q