Browse Source

Another simple test.

pull/50/head
Rafal Kupiec 1 year ago
parent
commit
58b63a9f16
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 18 additions and 0 deletions
  1. +17
    -0
      tests/bin_format.aer
  2. +1
    -0
      tests/bin_format.exp

+ 17
- 0
tests/bin_format.aer View File

@ -0,0 +1,17 @@
class Program {
string fmt_binary(int $x, int $numbits = 8) {
string $bin;
string $rtnval = '';
$bin = decbin($x);
$bin = substr(str_repeat(0, $numbits), 0, $numbits - strlen($bin)) + $bin;
for($x = 0; $x < $numbits / 4; $x++) {
$rtnval += ' ' + substr($bin, $x * 4, 4);
}
return ltrim($rtnval);
}
void main() {
var_dump($this->fmt_binary(2541));
}
}

+ 1
- 0
tests/bin_format.exp View File

@ -0,0 +1 @@
string(9 '0000 1001')

Loading…
Cancel
Save