Round Function | |
Round a number to a specified number of digits.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax FUNCTION Round(
nNumber AS USUAL,
siDecimals AS LONG
) AS USUAL
public static Usual Round(
Usual nNumber,
int siDecimals
)
Request Example
View SourceParameters
- nNumber
- Type: Usual
The number to round. - siDecimals
- Type: Long
The number of decimal places to retain. Specifying a 0 or negative value for siDecimals rounds to whole numbers.
A negative siDecimals also indicates the number of digits to the left of the decimal point to round (see the example).
Return Value
Type:
UsualRemarks
Digits below 5 are rounded down. Digits from 5 to 9 are rounded up.
The display of the return value does not obey the decimals setting unless SetFixed() is TRUE.
If SetFixed() is FALSE, the display of the return value contains siDecimals decimal digits if siDecimals is greater than 0, and zero decimal digits if siDecimals is less than or equal to 0.
Examples
These examples round values with decimal digits:
1SetDecimal(2)
2SetFixed(TRUE)
3? Round(10.4, 0)
4? Round(10.5, 0)
5? Round(10.51, 0)
6? Round(10.49999999999999, 2)
These examples use a negative
siDecimals argument to round numeric values to whole numbers:
1? Round(101.99, -1)
2? Round(109.99, -1)
3? Round(109.99, -2)
See Also