3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $n = 48; //print the last n digits from mysterycode aka greyCode for($k=pow(2,$n)-$n;$k<pow(2,$n);$k++){ //echo tobin($mC[$k], $n)."\r\n<br>"; echo tobin(floatval(binaryToGray($k)),$n)."\r\n"; } function binaryToGray($num) { return $num ^ ($num >> 1); } function tobin($nr,$n){ $cnt = $n;//pow(2,$n); $converted_nr = base_convert($nr,10,2); if (strlen($converted_nr)<$cnt){ return leadZero($converted_nr,$cnt-strlen($converted_nr)-1); }else{ return $converted_nr; } } function leadZero($a,$nrZeros){ return str_pad($a, $nrZeros, "0", STR_PAD_LEFT); }
based on ZfFkL
Output for 5.6.0 - 5.6.30, hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.3.0rc3
101000000000000000000000000000000000000001000010110 101000000000000000000000000000000000000001000010110 101000000000000000000000000000000000000001001111010 101000000000000000000000000000000000000001001111010 101000000000000000000000000000000000000001001111010 101000000000000000000000000000000000000001001111010 101000000000000000000000000000000000000001001111010 101000000000000000000000000000000000000001001111010 101000000000000000000000000000000000000001000010110 101000000000000000000000000000000000000001000010110 101000000000000000000000000000000000000001000010110 101000000000000000000000000000000000000001000010110 101000000000000000000000000000000000000001000010110 101000000000000000000000000000000000000001000010110 101000000000000000000000000000000000000001000010110 101000000000000000000000000000000000000001000010110 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000011101010 101000000000000000000000000000000000000000011101010 101000000000000000000000000000000000000000011101010 101000000000000000000000000000000000000000011101010 101000000000000000000000000000000000000000011101010 101000000000000000000000000000000000000000011101010 101000000000000000000000000000000000000000101001110 101000000000000000000000000000000000000000101001110 101000000000000000000000000000000000000000101001110 101000000000000000000000000000000000000000101001110 101000000000000000000000000000000000000000011101010 101000000000000000000000000000000000000000101001110 101000000000000000000000000000000000000000011101010 101000000000000000000000000000000000000000011101010 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000000100010 101000000000000000000000000000000000000000000100010 101000000000000000000000000000000000000000010000110 101000000000000000000000000000000000000000000100010 101000000000000000000000000000000000000000000100010 101000000000000000000000000000000000000000000100010 101000000000000000000000000000000000000000000100010 101000000000000000000000000000000000000000000100010