ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


rounding

This is an old revision of the document!


Rounding

There are four rounding modes:

  • trunc – zeroes the fractional part of the number
  • floor – rounds the number down
  • ceil – round the number up
  • round – rounds the number to the closest integer

Rounding table:

x round(x) floor(x) ceil(x) trunc(x)
2.3 2 2 3 2
3.8 4 3 4 3
5.5 6 5 6 5
-2.3 -2 -3 -2 -2
-3.8 -4 -4 -3 -3
-5.5 -5 -6 -5 -5

Every rounding mode is available as two functions. The ones with the i prefix in the name return an integer, while the ones without return a fixed-point number.

rounding.1489588778.txt.gz · Last modified: 2017/03/15 16:39 by korshun