Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
23
Task/Binary-digits/Free-Pascal-Lazarus/binary-digits.pas
Normal file
23
Task/Binary-digits/Free-Pascal-Lazarus/binary-digits.pas
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