Aer Interpreter Source
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
383 B

  1. class Program {
  2. string fmt_binary(int $x, int $numbits = 8) {
  3. string $bin;
  4. string $rtnval = '';
  5. $bin = decbin($x);
  6. $bin = substr(str_repeat(0, $numbits), 0, $numbits - strlen($bin)) + $bin;
  7. for($x = 0; $x < $numbits / 4; $x++) {
  8. $rtnval += ' ' + substr($bin, $x * 4, 4);
  9. }
  10. return ltrim($rtnval);
  11. }
  12. public void main() {
  13. var_dump($this->fmt_binary(2541));
  14. }
  15. }