The round() function returns the rounded value of a specified field. The field can be rounded on either side of the decimal separator.
round(field, side, expression {, mode})
• field – A currency or variable currency field or value to round.
• side – A constant indicating which side of the decimal separator to begin rounding on:
Constant |
Description |
---|---|
DECIMALRIGHT |
Round the currency value beginning the specified number of places to the right of the decimal separator. |
DECIMALLEFT |
Round the currency value beginning the specified number of places left of the decimal separator. |
• expression – An integer indicating the number of places to the right or left of the decimal separator the specified field will be rounded to. The allowable range to the right of the decimal separator is 0 to 5 for currency values and 0 to 15 for variable currency values.
• mode – An optional integer that indicates how the value will be rounded. It corresponds to one of the following constants:
Constant |
Description |
Examples* |
---|---|---|
ROUNDMODE_UP |
Always round up. |
4.651 –> 4.66 4.655 –> 4.66 4.659 –> 4.66 |
ROUNDMODE_DOWN |
Always round down. |
4.651 –> 4.65 4.655 –> 4.65 4.659 –> 4.65 |
ROUNDMODE_HALF_UP |
If the only digit following the digit to be rounded is 5, round up. |
4.675 –> 4.68 4.6751 –> 4.68 |
ROUNDMODE_HALF_DOWN |
If the only digit following the digit to be rounded is 5, round down. |
4.675 –> 4.67 4.6751 –> 4.68 |
ROUNDMODE_HALF_EVEN |
If the only digit following the digit to be rounded is 5 and the preceding digit is odd, round up. Otherwise, truncate. |
4.675 –> 4.68 4.685 –> 4.68 |
ROUNDMODE_CEILING |
Always round toward positive infinity. |
4.655 –> 4.66 -4.655 –> -4.65 |
ROUNDMODE_FLOOR |
Always round toward negative infinity. |
4.655 –> 4.65 -4.655 –> -4.66 |
*Rounding to two decimal places |
If this parameter isn’t supplied, ROUNDMODE_HALF_UP is used.
Currency or variable currency