RDN - Round Nearest #
Round the value in Operand 2 to the nearest value of Operand 3, and store the result in Operand 1.
Round Nearest allows the user to specify, in Operand 3, the level of rounding. For example, it is acceptable to round to the nearest 2 decimal places with an Operand 3 value of .01, or to round to the nearest half hour with an Operand3 value of .5.
Examples:
Operand 2 | Operand 3 | Result (stored in Operand 1) |
1011.39823 | 0.1 | 1011.4 |
1011.39423 | 0.005 | 1011.395 |
3.6 | 0.5 | 3.5 |
It is even acceptable to round to the nearest .25 (i.e. quarter of an hour). The program will accept any value in Operand 3 and round to it.
- Statement
- Divide the value in PC 100 by 2, and round the resulting value to the nearest dollar.
Line | CMD | OT | Operand 1 | OPER | OT | Operand2 | OT | Operand3 | If Goto | Else GoTo |
---|---|---|---|---|---|---|---|---|---|---|
00010 | LET | V | PC 100 DIV BY 2 | DIV | PC | 100 | N | 2 | 00020 | |
00020 | LET | PC | 100 | RDN | V | PC 100 DIV BY 2 | N | 1 | 99999 | |
99999 | EXIT | 99999 |