Question
In Mapper logics, there is a Rounding item in the property of logics in Number > Calculation category (Addition, Subtraction, Multiplication, Division, and Modulo), and there are eight processes that can be selected.
How the result of each rounding process will be?
Answer
The specifications of the eight rounding processes are the same as the rounding operations implemented in java.
The concrete example are shown below.
1. Round to 0
The process does not increase the digits preceding the decimal part to be discarded.
Example:
5.5 → 5
2.5 → 2
-1.1 → -1
-1.6 → -1
-2.5 → -2
2. Round away from 0
The process always increase the digits preceding the non-zero decimal part to be discarded.
Example:
5.5 → 6
2.5 → 3
-1.1 → -2
-1.6 → -2
-2.5 → -3
3. Round toward positive infinity
For positive numbers, the same action as Round away from 0 is used.
For negative numbers, the action is the same as Round to 0.
Example:
5.5 → 6
2.5 → 3
-1.1 → -1
-1.6 → -1
-2.5 → -2
4. Rounding toward negative infinity
For positive numbers, the same action as Round to 0 is used.
For negative numbers, the same action as Round away from 0 is used.
Example:
5.5 → 5
2.5 → 2
-1.1 → -2
-1.6 → -2
-2.5 → -3
5. Round to nearest number(Round up if equidistant)
If the fraction is exactly 0.5, the process rounds up the number.
Example:
5.5 → 6
2.5 → 3
-1.1 → -1
-1.6 → -2
-2.5 → -3
6. Round to nearest number(Round down if equidistant)
If the fraction is exactly 0.5, the process rounds down the number.
Example:
5.5 → 5
2.5 → 2
-1.1 → -1
-1.6 → -2
-2.5 → -2
7. Round to nearest number(Round to even number if equidistant)
If the fraction is exactly 0.5, the process rounds up or down to the nearest even number.
Example:
5.5 → 6
2.5 → 2
-1.1 → -1
-1.6 → -2
-2.5 → -2
8. Do not round
This mode indicates that no rounding is required.
The process returns an error if the result is specified by an operation that is not exact.
Example:
5.5 → Error
2.5 → Error
1.0 → 1
-1.0 → -1
-2.5 → Error
Comments
0 comments
Article is closed for comments.