This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rounding [2017/04/15 17:47] – korshun | rounding [2019/04/18 22:05] – korshun | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Rounding ===== | + | ===== Rounding |
+ | |||
+ | ACSUtils provides a full set of functions to round fixed-point numbers to integers. | ||
There are four rounding modes: | There are four rounding modes: | ||
Line 8: | Line 10: | ||
* '' | * '' | ||
- | Rounding | + | Example rounding |
^ x ^ round(x) ^ floor(x) ^ ceil(x) ^ trunc(x) ^ | ^ x ^ round(x) ^ floor(x) ^ ceil(x) ^ trunc(x) ^ | ||
- | ^ 2.3| 2| 2| | + | ^ 1.3| 1| 1| |
- | ^ 3.8| 4| 3| | + | ^ 1.5| 2| 1| |
- | ^ 5.5| 6| 5| | + | ^ 1.8| 2| 1| |
- | ^ -2.3| -2| -3| -2| -2| | + | ^ -1.3| -1| -2| -1| -1| |
- | ^ -3.8| -4| -4| -3| -3| | + | ^ -1.5| -1| -2| -1| -1| |
- | ^ -5.5| -5| -6| -5| -5| | + | ^ -1.8| -2| -2| -1| -1| |
+ | |||
+ | Every rounding mode is available as two functions: | ||
+ | * Functions without the '' | ||
+ | * Functions with the '' | ||
+ | |||
+ | ^ Mode ^ fixed result ^ int result ^ | ||
+ | ^ floor | '' | ||
+ | ^ ceil | '' | ||
+ | ^ round | '' | ||
+ | ^ trunc | '' | ||
- | Every rounding mode is available as two functions. The ones with the '' | + | <note important> |
- | ^ Mode ^ as fixed ^ as int ^ | ||
- | ^ floor | [[functions: | ||
- | ^ ceil | [[functions: | ||
- | ^ round | [[functions: | ||
- | ^ trunc | [[functions: | ||
+ | </ |