Difference between revisions of "Round/de"
From Lazarus wiki
Jump to navigationJump to search (→Code:) |
|||
Line 37: | Line 37: | ||
* [[Div]] | * [[Div]] | ||
− | [[Category:Pascal]] | + | [[Category:Pascal/de]] |
Revision as of 21:26, 22 March 2018
Rundet eine Fliesskommazahl auf eine Ganzzahl.
Round
Deklaration:
function Round(X: Real): Longint;
Beispiel:
Code:
var
i1, i2: Integer;
begin
WriteLn( Round(8.7) );
WriteLn( Round(8.3) );
// Beispiele für "Banker-Runden" - .5 wird auf die nächste gerade Zahl eingestellt
WriteLn( Round(2.5) );
WriteLn( Round(3.5) );
i := Round(12.50); // Rundet ab
WriteLn(i);
i := Round(12.51); // Rundet auf
WriteLn(i);
end.
Ausgabe:
9
8
2
4
12
13
See also: