round, round up, round down
Rounds the number (automatically or up or down) to the next rounding interval. The rounding intervals may be integers as well as non-integers. Example: 0.25 rounds in steps of 0.25.
Indirect parameter passing is disabled
1, 2
No. | Type | Description |
---|---|---|
1 input |
numeral | Number to round Any positive or negative number |
Opt. 2 input |
numeral | Rounding interval Defines the steps how the rounding is done. E.g. 0.4 rounds numbers to 0, 0.4, 0.8, 1.2, and the same in the negative direction. |
Type | Description |
---|---|
numeral | Result Rounded number |
Values provided is not a numerals
rounding intervals is negative or zero
for all parameters( { {1.4, 1}, {1.5,1}, {-1.5,1}, {18, 10}, { 3.14159, 0.01 } }, p[] )
echo( "round ", p[]{0}, " using ", p[]{1}, ": ", round( p[]{0}, p[]{1} ),
" up: ", round up( p[]{0}, p[]{1} ), " down: ", round down( p[]{0}, p[]{1} ) );
round 1.4 using 1: 1 up: 2 down: 1
round 1.5 using 1: 2 up: 2 down: 1
round -1.5 using 1: -2 up: -2 down: -1
round 18 using 10: 20 up: 20 down: 10
round 3.14159 using 0.01: 3.14 up: 3.15 down: 3.14