Another simple test.
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
67f40db553
commit
58b63a9f16
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
string(9 '0000 1001')
|
Loading…
Reference in New Issue