Round/eo: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | La [[RTL]] [[System unit|Systema unuo]] enhavas [[Function|funkcion]] **Round**, kiu rondigas [[Real]]-tipan valoron al [[Integer|Entjera]]-tipa valoro. Ĝia eniga parametro estas [[expression|esprimo]] kaj Round revenigos [[Int64]] valoron kiu estas la valoro de la enigo rondigita al la plej proksima entjero. Se la enigo estas ekzakte meze de la du entjeroj - N.5 - tiam "rondigo de bakisto" estas uzata, kies rezulto estas la plej proksima para nombro. | |
| 2 | 2 | ||
| 3 | 3 | ## Deklaro | |
| 4 | 4 | ||
| 5 | 5 | ``` pascal | |
| 6 | 6 | function Round(X: Real): int64; | |
| 7 | 7 | ``` | |
| 8 | 8 | ||
| 9 | 9 | ## Ekzemplo de Uzado | |
| 10 | 10 | ||
| 11 | 11 | ``` pascal | |
| 12 | 12 | begin | |
| 13 | 13 | WriteLn( Round(8.7) ); | |
| 14 | 14 | WriteLn( Round(8.3) ); | |
| 15 | 15 | // examples of "bankers rounding" - .5 is adjusted to the nearest even number | |
| 16 | 16 | WriteLn( Round(2.5) ); | |
| 17 | 17 | WriteLn( Round(3.5) ); | |
| 18 | 18 | end. | |
| 19 | 19 | ``` | |
| 20 | 20 | ||
| 21 | 21 | ### Output | |
| 22 | 22 | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 23 | + | ```text | |
| 24 | + | 9 | |
| 25 | + | 8 | |
| 26 | + | 2 | |
| 27 | + | 4 | |
| 28 | + | ``` | |
| 27 | 29 | ||
| 28 | 30 | ## See also | |
| 29 | 31 | ||
| 30 | 32 | - [`system.round`](https://www.freepascal.org/docs-html/rtl/system/round.html) | |
| 31 | 33 | - [`math.ceil`](https://www.freepascal.org/docs-html/rtl/math/ceil.html) - superrondigu | |
| 32 | 34 | - [`math.floor`](https://www.freepascal.org/docs-html/rtl/math/floor.html) - subrondigu | |
| 33 | 35 | - [[Frac|frac]] - revenigos la frakcian parton de glitpunkta valoro | |
| 34 | 36 | - [[Trunc|trunc]] - rondigas al nulo | |
| 35 | 37 | - [[Int|int]] - revenigos la entjera parto de glitpunkta valoro | |
| 36 | 38 | - [[Div|div]] - entjera divido | |
| 37 | 39 | - [[Comparison of approaches for rounding to an integer|Komparo de alproksimiĝoj por rondigi al entjero]] | |
| 38 | 40 | ||
| 39 | 41 | --- | |
| 40 | 42 | *From the Free Pascal wiki, page "Round/eo", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
