Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
21
Task/Binary-digits/S-lang/binary-digits.slang
Normal file
21
Task/Binary-digits/S-lang/binary-digits.slang
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
define int_to_bin(d)
|
||||
{
|
||||
variable m = 0x40000000, prn = 0, bs = "";
|
||||
do {
|
||||
if (d & m) {
|
||||
bs += "1";
|
||||
prn = 1;
|
||||
}
|
||||
else if (prn)
|
||||
bs += "0";
|
||||
m = m shr 1;
|
||||
|
||||
} while (m);
|
||||
|
||||
if (bs == "") bs = "0";
|
||||
return bs;
|
||||
}
|
||||
|
||||
() = printf("%s\n", int_to_bin(5));
|
||||
() = printf("%s\n", int_to_bin(50));
|
||||
() = printf("%s\n", int_to_bin(9000));
|
||||
Loading…
Add table
Add a link
Reference in a new issue