VC10DivRound
V = Variables
C = Calculation functions
The VC10DivRound function divides a number by a factor 10 or a multiple of 10 and applies an approximation by the method of rounding. The value is then first divided by the 10^cdec value and then the following rule is applied:
-
If the figure immediately to the right of the decimal point is 1, 2, 3 or 4 it leaves unchanged the integer value
-
If is 5, 6, 7, 8 or 9 it increases by one the integer value
the function then returns the integer value of the number.
IMPLEMENTATION
VC10DivRound (valIn, cdec, valOut)
Parameters:
IN/OUT | VARIABLE TYPE | EXAMPLE NAME | DIM | |
---|---|---|---|---|
IN | GLOBAL / SYSTEM | valIn | L | Value to be processed |
IN | GLOBAL / SYSTEM | cdec | B | Number of decimal digits (0÷3) |
OUT | GLOBAL / SYSTEM | valOut | L | Return value (rounded) |
Example
In the example you want to round the value passed to 565, with two decimal places.
The resulting value will be 6.
MAIN: valIn = 565 cdec = 2 VC10DivRound (valIn, cdec, valOut) glVarArrot = valOut WAIT 1 JUMP MAIN END