3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $dec = intval((-1 * PHP_INT_MAX) + 1); var_dump(decbin($dec), dec2bin($dec)); function dec2bin($dec) { if ($dec == 0) { return 0; } $sgn = 1; if ($dec < 0) { $sgn = -1; $dec = (PHP_INT_MAX + $dec) + 1; } $bin = ''; while ($dec > 0) { $bin = ($dec & 1) . $bin; $dec >>= 1; } return $sgn > 0 ? $bin : '1' . str_pad($bin, 63, '0', STR_PAD_LEFT); }
based on o3tbK
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0rc3
string(64) "1000000000000000000000000000000000000000000000000000000000000010" string(64) "1000000000000000000000000000000000000000000000000000000000000010"