This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| rounding [2019/04/18 19:09] – 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. | ACSUtils provides a full set of functions to round fixed-point numbers to integers. | ||
| - | < | + | < |
| - | Before using ACSUtils, rename either the built-in functions (by editing '' | + | Before using ACSUtils, rename either the built-in functions (by editing '' |
| </ | </ | ||
| + | |||
| + | ===== Rounding modes ===== | ||
| There are four rounding modes: | There are four rounding modes: | ||
| Line 15: | Line 19: | ||
| * '' | * '' | ||
| - | 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| | ||
| + | |||
| + | ===== Functions ===== | ||
| Every rounding mode is available as two functions: | Every rounding mode is available as two functions: | ||
| * Functions without the '' | * Functions without the '' | ||
| - | * Functions with the '' | + | * Functions with the '' |
| ^ Mode ^ fixed result ^ int result ^ | ^ Mode ^ fixed result ^ int result ^ | ||
| Line 34: | Line 40: | ||
| ^ round | '' | ^ round | '' | ||
| ^ trunc | '' | ^ trunc | '' | ||
| + | |||