blob: 244d624d30eec4afd40def8ce70e57364df54ff3 (
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
32
|
The utpl language supports modulo divisions, however they're only defined
for integer values.
-- Expect stdout --
If both operands are integers or convertible to integers,
the modulo division yields the remainder:
10 % 4 = 2
"10" % 4 = 2
10 % "4" = 2
"10" % "4" = 2
If either operand is a double value, the modulo operation
yields NaN:
10.0 % 4 = NaN
10 % 4.0 = NaN
"10.0" % 4 = NaN
-- End --
-- Testcase --
If both operands are integers or convertible to integers,
the modulo division yields the remainder:
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 NaN:
10.0 % 4 = {{ 10.0 % 4 }}
10 % 4.0 = {{ 10 % 4.0 }}
"10.0" % 4 = {{ "10.0" % 4 }}
-- End --
|