Trunc/fi: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 1 | + |  | |
| 2 | 2 | ||
| 3 | 3 | Free Pascalin [[RTL/fi|RTL]] [[Unit/fi|käännösyksikkö]] [[System unit/fi|System]] sisältää [[Function/fi|funktion]] **trunc**, mikä katkaisee [[Real/fi|reaaliluku]] tyyppisen arvon [[Integer/fi|Integer]]-tyyppiseksi arvoksi. Sille annetaan parametriksi realilukutyyppinen [[expression/fi|lauseke]] ja trunc palauttaa [[Int64/fi|Int64]] arvon jonka desimaaliosa on poistettu (eli pyöristää kohti nollaa). | |
| 4 | 4 | ||
| 5 | 5 | ## Määrittely | |
| 6 | 6 | ||
| 7 | 7 | ``` pascal | |
| 8 | 8 | function Trunc(X: Real): Longint; | |
| 9 | 9 | ``` | |
| 10 | 10 | ||
| 11 | 11 | ## Käyttöesimerkki | |
| 12 | 12 | ||
| 13 | 13 | ``` pascal | |
| 14 | 14 | begin | |
| 15 | 15 | WriteLn( Trunc(8.7) ); | |
| 16 | 16 | WriteLn( Trunc(8.3) ); | |
| 17 | 17 | WriteLn( Trunc(-8.7) ); | |
| 18 | 18 | WriteLn( Trunc(-8.3) ); | |
| 19 | 19 | ||
| 20 | 20 | end; | |
| 21 | 21 | ``` | |
| 22 | 22 | ||
| 23 | 23 | ### Tulostaa | |
| 24 | 24 | ||
| 25 | 25 | `8`\ | |
| 26 | 26 | `8`\ | |
| 27 | 27 | `-8`\ | |
| 28 | 28 | `-8` | |
| 29 | 29 | ||
| 30 | 30 | ## Katso myös | |
| 31 | 31 | ||
| 32 | 32 | - [[Round/fi|round]] | |
| 33 | 33 | - [`math.ceil`](https://www.freepascal.org/docs-html/rtl/math/ceil.html) - pyöristää ylöspäin | |
| 34 | 34 | - [`math.floor`](https://www.freepascal.org/docs-html/rtl/math/floor.html) - pyoristää alaspäin | |
| 35 | 35 | - [[Trunc/fi|trunc]] - pyöristää kohti nollaa | |
| 36 | 36 | - [[Int/fi|int]] - palauttaa kokonaisosan reaalilukuarvosta. | |
| 37 | 37 | - [[Div/fi|div]] - kokonaisluku jakolasku | |
| 38 | 38 | ||
| 39 | 39 | - [[Comparison of approaches for rounding to an integer]] | |
| 40 | 40 | ||
| 41 | 41 | --- | |
| 42 | 42 | *From the Free Pascal wiki, page "Trunc/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).* |
