This topic describes how to use the four operations.
The four operations are further divided into addition, subtraction, multiplication, division (basic), division (advanced), and rounding.
When decimals are involved in the results of addition, subtraction, multiplication, and division (basic), they are rounded to two decimal places by default. Example: 1.234*5=6.17 and 1/5=0.20.
The last two digits of division (advanced) results are handled in the same way as rounding modes.
Seven rounding modes are supported. For each mode, you must specify the number of decimal places to be retained. In scale (1,2), 1 indicates that 1 decimal place is retained. 2 indicates that the round_mode parameter is set to 2. The following table describes the round_mode parameter.
NoteAssume that two decimal places are retained in the following table.
round_mode value
Description
Example
0
Rounding up mode, away from zero.
For example, 1.234 is rounded to 1.24 and -1.234 is rounded to -1.24.
1
Rounding down mode, towards zero.
For example, 1.234 is rounded to 1.23 and -1.234 is rounded to -1.23.
2
Ceiling mode, towards positive infinity.
For example, 1.234 is rounded to 1.24 and -1.234 is rounded to -1.23.
3
Floor mode, towards negative infinity.
For example, 1.234 is rounded to 1.23 and -1.234 is rounded to -1.24.
4
Rounding half down mode, to round towards the nearest neighbor unless both neighbors are equidistant, in which case round towards zero.
If both neighbors are equidistant, it is the same as mode 0. If not, it is the same as mode 1. For example, 1.235 is rounded to 1.24 and -1.235 is rounded to -1.24.
5
Rounding half up mode, to round towards the nearest neighbor unless both neighbors are equidistant, in which case round away from zero.
If both neighbors are equidistant, it is the same as mode 1. If not, it is the same as mode 0. For example, 1.235 is rounded to 1.23 and -1.235 is rounded to -1.23.
6
Rounding half even mode, to round towards the nearest neighbor unless both neighbors are equidistant, in which case round towards the even neighbor.
That is also known as the banker's algorithm. For example, 1.235 is rounded to 1.24 and 1.245 is rounded to 1.24.