This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
new:rounding [2018/02/16 22:15] – created korshun | new:rounding [2019/04/19 21:41] (current) – removed korshun | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Rounding functions ===== | ||
- | These functions round fixed-point numbers to one of the two nearby integers. | ||
- | |||
- | There are four rounding modes: | ||
- | |||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | |||
- | Rounding table: | ||
- | |||
- | ^ x ^ round(x) ^ floor(x) ^ ceil(x) ^ trunc(x) ^ | ||
- | ^ | ||
- | ^ | ||
- | ^ | ||
- | ^ -1.3| -1| -2| | ||
- | ^ -1.8| -2| -2| | ||
- | ^ -1.5| -1| -2| | ||
- | |||
- | Every rounding mode is available as two functions. The ones with the '' | ||
- | |||
- | ^ Mode ^ as fixed ^ as int ^ | ||
- | ^ floor | '' | ||
- | ^ ceil | '' | ||
- | ^ round | '' | ||
- | ^ trunc | '' | ||
- | |||
- | So the full function list is as follows: | ||
- | |||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | |||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' |