September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
23
Task/Binary-digits/Free-Pascal/binary-digits.free
Normal file
23
Task/Binary-digits/Free-Pascal/binary-digits.free
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
program binaryDigits(input, output, stdErr);
|
||||
{$mode ISO}
|
||||
|
||||
function binaryNumber(const value: nativeUInt): shortString;
|
||||
const
|
||||
one = '1';
|
||||
var
|
||||
representation: shortString;
|
||||
begin
|
||||
representation := binStr(value, bitSizeOf(value));
|
||||
// strip leading zeroes, if any; NB: mod has to be ISO compliant
|
||||
delete(representation, 1, (pos(one, representation)-1) mod bitSizeOf(value));
|
||||
// traditional Pascal fashion:
|
||||
// assign result to the (implicitely existent) variable
|
||||
// that is named like the function’s name
|
||||
binaryNumber := representation;
|
||||
end;
|
||||
|
||||
begin
|
||||
writeLn(binaryNumber(5));
|
||||
writeLn(binaryNumber(50));
|
||||
writeLn(binaryNumber(9000));
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue