Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Binary-digits/Cowgol/binary-digits.cowgol
Normal file
20
Task/Binary-digits/Cowgol/binary-digits.cowgol
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue