Round/de

From Lazarus wiki
Revision as of 21:09, 22 March 2018 by Mathias (talk | contribs) (Created page with "Rundet eine Fliesskommazahl auf eine Ganzzahl. =Round= ==Deklaration:== <syntaxhighlight>function Round(X: Real): Longint;</syntaxhighlight> ==Beispiel:== ===Code:=== <synta...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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) );
  // examples of "bankers rounding" - .5 is adjusted to the nearest even number
  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: