Welcome to the Creatures Wiki! Log in and join the community.
MODV
Jump to navigation
Jump to search
MODV is a CAOS command for arithmetic.
Usage[edit]
Syntax: MODV var (int variable) x (int)
Sets var to the remainder of var when divided by x, otherwise known as var mod x. Equivalent to var = var % x
.
Both arguments must be integers. If x is not, it will be cast. If var is not, the command will fail.
Examples[edit]
Add the 24-hour format times va00 and va01, storing the result in va00. For instance, 0520 + 1240 = 1800, and 0940 + 1624 = 0204
* first separate the minutes: SETV va02 va00 MODV va02 100 SETV va03 va01 MODV va03 100 * add minutes: ADDV va02 va03 * store the carry: SETV va04 va02 DIVV va04 60 * clock the minutes: MODV va02 60 * separate the hours (int division): DIVV va00 100 DIVV va01 100 * add them: ADDV va00 va01 ADDV va00 va04 *clock them: MODV va00 24 * recombine into 24-hour time: MULV va00 100 ADDV va00 va02
An implementation of MODV va00 va01
using a loop.
DOIF va00 ge va01 LOOP SUBV va00 va01 UNTL va00 lt va01 ENDI