This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| rounding [2017/04/15 14:47] – korshun | rounding [2019/08/26 18:02] (current) – korshun | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Rounding ===== | + | ====== Rounding====== |
| + | |||
| + | ===== Introduction ===== | ||
| + | |||
| + | ACSUtils provides a full set of functions to round fixed-point numbers to integers. | ||
| + | |||
| + | <note warning> | ||
| + | |||
| + | Before using ACSUtils, rename either the built-in functions (by editing '' | ||
| + | </ | ||
| + | |||
| + | ===== Rounding modes ===== | ||
| There are four rounding modes: | There are four rounding modes: | ||
| Line 8: | Line 19: | ||
| * '' | * '' | ||
| - | 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) ^ | ||
| - | ^ 2.3| 2| 2| | + | ^ 1.3| 1| 1| |
| - | ^ 3.8| 4| 3| | + | ^ 1.5| 1 or 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| -2 or -1| -2| -1| -1| |
| - | ^ -5.5| -5| -6| -5| -5| | + | ^ -1.8| -2| -2| -1| -1| |
| + | |||
| + | ===== Functions ===== | ||
| + | |||
| + | 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 '' | ||
| - | ^ Mode ^ as fixed ^ as int ^ | ||
| - | ^ floor | [[functions: | ||
| - | ^ ceil | [[functions: | ||
| - | ^ round | [[functions: | ||
| - | ^ trunc | [[functions: | ||