20 lines
338 B
Text
20 lines
338 B
Text
include "cowgol.coh";
|
|
|
|
sub print_binary(n: uint32) is
|
|
var buffer: uint8[33];
|
|
var p := &buffer[32];
|
|
[p] := 0;
|
|
|
|
while n != 0 loop
|
|
p := @prev p;
|
|
[p] := ((n as uint8) & 1) + '0';
|
|
n := n >> 1;
|
|
end loop;
|
|
|
|
print(p);
|
|
print_nl();
|
|
end sub;
|
|
|
|
print_binary(5);
|
|
print_binary(50);
|
|
print_binary(9000);
|