Sign in Join
Wiki copytemporary

Round/fi

Deutsch · English · Esperanto · Suomi · Русский

Free Pascalin RTL käännösyksikkö System sisältää funktion Round, mikä pyöristää reaaliluku tyyppisen arvon Integer-tyyppiseksi arvoksi. Sille annetaan parametriksi realilukutyyppinen lauseke ja Round palauttaa 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.

Määrittely

pascal
function Round(X: Real): int64;

Käyttöesimerkki

pascal
begin
   WriteLn( Round(8.7) );
   WriteLn( Round(8.3) );
   // esimerkit "pankkiirin pyöristyksestä" - .5 arvotetaan lähimpään parilliseen lukuun
   WriteLn( Round(2.5) );
   WriteLn( Round(3.5) );
end.

Tulostaa

 9
 8
 2
 4

Katso myös


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.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.