September 2002
Intermediate to advanced
1024 pages
30h 52m
English
MOD
The MOD function returns the remainder of one number when divided by a second number. The specification for the MOD function is:
FUNCTION MOD (dividendNUMBER,divisorNUMBER) RETURN NUMBER;
If the divisor is zero, then the
dividend is returned unchanged. Here are some
examples of MOD:
MOD (10, 5) --> 0 MOD (2, 1) --> 0 MOD (3,2) --> 1
You can use MOD to determine quickly if a number is odd or even:
FUNCTION is_odd (num_in IN NUMBER) RETURN BOOLEAN IS BEGIN RETURN MOD (num_in, 2) = 1; END; FUNCTION is_even (num_in IN NUMBER) RETURN BOOLEAN IS BEGIN RETURN MOD (num_in, 2) = 0; END;
Read now
Unlock full access