ROUND - Zaokruži na najbliži cijeli broj.
Sintaksa: FUNCTION ROUND (vrijednost:<REAL>): <LONGINTEGER>;
ROUND(a) = cio dio od (a + 0.5)
Tabela d.23. ROUND - funkcija
Listing programa |
Ekran |
Opis |
PROGRAM Slucajan; |
|
Zaglavlje |
VAR |
|
|
i: REAL; |
|
String |
BEGIN |
|
|
WRITELN('REAL ZOKRUZEN'); |
REAL ZOKRUZEN |
|
i := 9.99; |
|
|
WRITELN(i, ROUND(i):10); |
9.99 10 |
Najbliži |
i := -9.99; |
|
|
WRITELN(i, ROUND(i):10); |
-9.99 -10 |
Najbliži |
i := 0.99; |
|
|
WRITELN(i, ROUND(i):10); |
0.99 1 |
Najbliži |
i := -0.99; |
|
|
WRITELN(i, ROUND(i):10); |
-0.99 -1 |
Najbliži |
i := 9.49; |
|
|
WRITELN(i, ROUND(i):10); |
9.49 9 |
Najbliži |
i := -9.49; |
|
|
WRITELN(i, ROUND(i):10); |
-9.49 -9 |
Najbliži |
i := 0.49; |
|
|
WRITELN(i, ROUND(i):10); |
0.49 0 |
Najbliži |
i := -0.49; |
|
|
WRITELN(i, ROUND(i):10); |
-0.49 0 |
Najbliži |
READLN;
END. |
|
Kraj programa |
Listing programa:
PROGRAM pROUND;
VAR
i: REAL;
BEGIN
WRITELN('REAL ZOKRUZEN');
i := 9.99;
WRITELN(i, ROUND(i):10);
i := -9.99;
WRITELN(i, ROUND(i):10);
i := 0.99;
WRITELN(i, ROUND(i):10);
i := -0.99;
WRITELN(i, ROUND(i):10);
i := 9.49;
WRITELN(i, ROUND(i):10);
i := -9.49;
WRITELN(i, ROUND(i):10);
i := 0.49;
WRITELN(i, ROUND(i):10);
i := -0.49;
WRITELN(i, ROUND(i):10);
READLN;
END.
Index
|
|