ROUND function
Purpose:
Rounds a floating point number.
Syntax:
RetVal = ROUND(Number AS DOUBLE, Decimals AS INTEGER)
Return Value:
- Data type: DOUBLE
RetVal Number rounded
to a precision of Decimals places.
Parameters:
- Data type: DOUBLE
Number Literal or variable floating point
number to be rounded.
- Data type: INTEGER
Decimals The decimal places of precision to
which Number is to be rounded.
|
Remarks:
👉 The BCX ROUND function
- rounds positive numbers, with a decimal value greater than or
equal to .5, towards positive infinity.
- truncates positive numbers with a decimal value less than
.5.
- rounds negative numbers, with a decimal value less than or
equal to -.5, towards negative infinity.
- truncates negative numbers with a decimal value more than
-.5.
Example:
DIM RetDbl#
FOR DOUBLE OO = 0.550 To 0.559 STEP 0.001
RetDbl# = ROUND(OO#, 2)
PRINT OO#, " ", RetDbl#
NEXT OO
?
FOR DOUBLE OO = -0.550 To -0.559 STEP -0.001
RetDbl# = ROUND(OO#, 2)
PRINT OO#, " ", RetDbl#
NEXT OO
Result:
0.55 0.55
0.551 0.55
0.552 0.55
0.553 0.55
0.554 0.55
0.555 0.56
0.556 0.56
0.557 0.56
0.558 0.56
0.559 0.56
-0.55 -0.55
-0.551 -0.55
-0.552 -0.55
-0.553 -0.55
-0.554 -0.55
-0.555 -0.56
-0.556 -0.56
-0.557 -0.56
-0.558 -0.56
-0.559 -0.56