summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/01_arithmetic/02_modulo
blob: c011e04259293163adb723991ee8e997cdfea128 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
The ucode language supports modulo divisions.

-- Expect stdout --
If both operands are integers or convertible to integers,
the modulo division yields the remaining integer value:
10 % 4 = 2
"10" % 4 = 2
10 % "4" = 2
"10" % "4" = 2

If either operand is a double value, the modulo operation
yields the remaining value as calculated by fmod(3):
10.2 % 4 = 2.2
10 % 4.3 = 1.4
"10.4" % 4 = 2.4
-- End --

-- Testcase --
If both operands are integers or convertible to integers,
the modulo division yields the remaining integer value:
10 % 4 = {{ 10 % 4 }}
"10" % 4 = {{ "10" % 4 }}
10 % "4" = {{ 10 % 4 }}
"10" % "4" = {{ "10" % "4" }}

If either operand is a double value, the modulo operation
yields the remaining value as calculated by fmod(3):
10.2 % 4 = {{ 10.2 % 4 }}
10 % 4.3 = {{ 10 % 4.3 }}
"10.4" % 4 = {{ "10.4" % 4 }}
-- End --