This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rounding [2019/04/18 21:43] – korshun | rounding [2019/04/20 03:14] – [Rounding modes] korshun | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Rounding | + | ===== Rounding ===== |
ACSUtils provides a full set of functions to round fixed-point numbers to integers. | ACSUtils provides a full set of functions to round fixed-point numbers to integers. | ||
+ | |||
+ | <note important> | ||
+ | |||
+ | Before using ACSUtils, rename either the built-in functions (by editing '' | ||
+ | </ | ||
+ | |||
+ | ==== Rounding modes ==== | ||
There are four rounding modes: | There are four rounding modes: | ||
Line 10: | Line 17: | ||
* '' | * '' | ||
- | Example rounding | + | A table that demonstrates the differences between rounding modes: |
^ x ^ round(x) ^ floor(x) ^ ceil(x) ^ trunc(x) ^ | ^ x ^ round(x) ^ floor(x) ^ ceil(x) ^ trunc(x) ^ | ||
^ | ^ | ||
- | ^ | + | ^ |
^ | ^ | ||
^ -1.3| -1| -2| | ^ -1.3| -1| -2| | ||
- | ^ -1.5| -1| -2| | + | ^ -1.5| -2 or -1| -2| |
^ -1.8| -2| -2| | ^ -1.8| -2| -2| | ||
- | Every rounding mode is available as two functions. The ones with the '' | + | ==== Rounding |
- | + | ||
- | ^ Mode ^ as fixed ^ as int ^ | + | |
- | ^ floor | '' | + | |
- | ^ ceil | '' | + | |
- | ^ round | '' | + | |
- | ^ trunc | '' | + | |
- | Example of the difference between | + | Every rounding mode is available as two functions: |
+ | * Functions without | ||
+ | * Functions with the '' | ||
- | * '' | + | ^ Mode ^ fixed result ^ int result ^ |
- | | + | ^ floor | '' |
+ | ^ ceil | '' | ||
+ | ^ round | '' | ||
+ | ^ trunc | '' | ||
- | So the full function list is as follows: | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | * '' |