Sign in Join
Wiki copytemporary

Trunc/fi: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Trunc/fi

OldNewLine
1+<img src="trunc.png" title="trunc.png" width="100" />
2+
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+
5+## Määrittely
6+
7+``` pascal
8+function Trunc(X: Real): Longint;
9+```
10+
11+## Käyttöesimerkki
12+
13+``` pascal
14+begin
15+ WriteLn( Trunc(8.7) );
16+ WriteLn( Trunc(8.3) );
17+ WriteLn( Trunc(-8.7) );
18+ WriteLn( Trunc(-8.3) );
19+
20+end;
21+```
22+
23+### Tulostaa
24+
25+`8`\
26+`8`\
27+`-8`\
28+`-8`
29+
30+## Katso myös
31+
32+- [[Round/fi|round]]
33+- [`math.ceil`](https://www.freepascal.org/docs-html/rtl/math/ceil.html) - pyöristää ylöspäin
34+- [`math.floor`](https://www.freepascal.org/docs-html/rtl/math/floor.html) - pyoristää alaspäin
35+- [[Trunc/fi|trunc]] - pyöristää kohti nollaa
36+- [[Int/fi|int]] - palauttaa kokonaisosan reaalilukuarvosta.
37+- [[Div/fi|div]] - kokonaisluku jakolasku
38+
39+- [[Comparison of approaches for rounding to an integer]]
40+
41+---
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).*

Back to history