Sign in Join
Wiki copytemporary

Trunc/fi: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11![](/wiki-images/e/ea/Trunc.png)
22
33Free 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).
44
55## Määrittely
66
77``` pascal
88function Trunc(X: Real): Longint;
99```
1010
1111## Käyttöesimerkki
1212
1313``` pascal
1414begin
1515 WriteLn( Trunc(8.7) );
1616 WriteLn( Trunc(8.3) );
1717 WriteLn( Trunc(-8.7) );
1818 WriteLn( Trunc(-8.3) );
1919
2020end;
2121```
2222
2323### Tulostaa
2424
25-`8`\
26-`8`\
27-`-8`\
28-`-8`
25+```text
26+8
27+8
28+-8
29+-8
30+```
2931
3032## Katso myös
3133
3234- [[Round/fi|round]]
3335- [`math.ceil`](https://www.freepascal.org/docs-html/rtl/math/ceil.html) - pyöristää ylöspäin
3436- [`math.floor`](https://www.freepascal.org/docs-html/rtl/math/floor.html) - pyoristää alaspäin
3537- [[Trunc/fi|trunc]] - pyöristää kohti nollaa
3638- [[Int/fi|int]] - palauttaa kokonaisosan reaalilukuarvosta.
3739- [[Div/fi|div]] - kokonaisluku jakolasku
3840
3941- [[Comparison of approaches for rounding to an integer]]
4042
4143---
4244*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).*

Back to history