Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,36 @@
|
|||
procedure writeInFixedFormat(n: real);
|
||||
const
|
||||
wholeNumberPlaces = 5;
|
||||
fractionalPlaces = 3;
|
||||
zeroDigit = '0';
|
||||
negative = '-';
|
||||
var
|
||||
signPresent: boolean;
|
||||
i: integer;
|
||||
begin
|
||||
// NOTE: This does not catch “negative” zero.
|
||||
signPresent := n < 0.0;
|
||||
if signPresent then
|
||||
begin
|
||||
write(negative);
|
||||
n := abs(n);
|
||||
end;
|
||||
|
||||
// determine number of leading zeros
|
||||
i := wholeNumberPlaces;
|
||||
if n > 0 then
|
||||
begin
|
||||
i := i - trunc(ln(n) / ln(10));
|
||||
end;
|
||||
|
||||
for i := i - 1 downto succ(ord(signPresent)) do
|
||||
begin
|
||||
write(zeroDigit);
|
||||
end;
|
||||
|
||||
// writes n with
|
||||
// - at least 0 characters in total
|
||||
// - exactly fractionalPlaces post-radix digits
|
||||
// rounded
|
||||
write(n:0:fractionalPlaces);
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue