Round/fi: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Round/fi
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Free Pascalin [[RTL/fi|RTL]] [[Unit/fi|käännösyksikkö]] [[System unit/fi|System]] sisältää [[Function/fi|funktion]] **Round**, mikä pyöristää [[Real/fi|reaaliluku]] tyyppisen arvon [[Integer/fi|Integer]]-tyyppiseksi arvoksi. Sille annetaan parametriksi realilukutyyppinen [[expression/fi|lauseke]] ja Round palauttaa [[Int64/fi|Int64]] arvon joka on pyöristetty lähimpään kokonaislukuun. Jos annettu parametri on tarkalleen puolivälissä kokonaislukua - N.5 - niin käytetään "pankkiirin" pyöristys sääntöä: tällöin tulos on lähin parillinen luku. | |
| 2 | + | ||
| 3 | + | ## Määrittely | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 6 | + | function Round(X: Real): int64; | |
| 7 | + | ``` | |
| 8 | + | ||
| 9 | + | ## Käyttöesimerkki | |
| 10 | + | ||
| 11 | + | ``` pascal | |
| 12 | + | begin | |
| 13 | + | WriteLn( Round(8.7) ); | |
| 14 | + | WriteLn( Round(8.3) ); | |
| 15 | + | // esimerkit "pankkiirin pyöristyksestä" - .5 arvotetaan lähimpään parilliseen lukuun | |
| 16 | + | WriteLn( Round(2.5) ); | |
| 17 | + | WriteLn( Round(3.5) ); | |
| 18 | + | end. | |
| 19 | + | ``` | |
| 20 | + | ||
| 21 | + | ### Tulostaa | |
| 22 | + | ||
| 23 | + | ` 9`\ | |
| 24 | + | ` 8`\ | |
| 25 | + | ` 2`\ | |
| 26 | + | ` 4` | |
| 27 | + | ||
| 28 | + | ## Katso myös | |
| 29 | + | ||
| 30 | + | - [`system.round`](https://www.freepascal.org/docs-html/rtl/system/round.html) | |
| 31 | + | - [`math.ceil`](https://www.freepascal.org/docs-html/rtl/math/ceil.html) - pyöristää ylöspäin | |
| 32 | + | - [`math.floor`](https://www.freepascal.org/docs-html/rtl/math/floor.html) - pyoristää alaspäin | |
| 33 | + | - [[Trunc/fi|trunc]] - pyöristää kohti nollaa | |
| 34 | + | - [[Int/fi|int]] - palauttaa kokonaisosan reaalilukuarvosta. | |
| 35 | + | - [[Div/fi|div]] - kokonaisluku jakolasku | |
| 36 | + | ||
| 37 | + | --- | |
| 38 | + | *From the Free Pascal wiki, page "Round/fi", 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).* |
