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.
Vectorization: These functions support vectorization in the 1st and 2nd function parameters.
Instead of providing a single value, you can provide a set or even a nested set which contain multiple values.
The function will then process every value and its return value contains a corresponding set containing all results.
Indirect parameter passing is disabled
Vectorization is allowed in the 1st and 2nd function parameters
1, 2
No. | Type | Description |
---|---|---|
1 input |
numeral set |
Number to round Any positive or negative number. Multiple numbers can be rounded if put into a set (vectorization). |
Opt. 2 input |
numeral set |
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 set |
Result Rounded number(s) |
Values provided is not a numerals
rounding intervals is negative or zero
for all( { {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