• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/01_arithmetic/02_modulo

  1 The ucode language supports modulo divisions.
  2 
  3 -- Expect stdout --
  4 If both operands are integers or convertible to integers,
  5 the modulo division yields the remaining integer value:
  6 10 % 4 = 2
  7 "10" % 4 = 2
  8 10 % "4" = 2
  9 "10" % "4" = 2
 10 
 11 If either operand is a double value, the modulo operation
 12 yields the remaining value as calculated by fmod(3):
 13 10.2 % 4 = 2.2
 14 10 % 4.3 = 1.4
 15 "10.4" % 4 = 2.4
 16 
 17 Modulo by zero yields NaN:
 18 1 % 0 = NaN
 19 -- End --
 20 
 21 -- Testcase --
 22 If both operands are integers or convertible to integers,
 23 the modulo division yields the remaining integer value:
 24 10 % 4 = {{ 10 % 4 }}
 25 "10" % 4 = {{ "10" % 4 }}
 26 10 % "4" = {{ 10 % 4 }}
 27 "10" % "4" = {{ "10" % "4" }}
 28 
 29 If either operand is a double value, the modulo operation
 30 yields the remaining value as calculated by fmod(3):
 31 10.2 % 4 = {{ 10.2 % 4 }}
 32 10 % 4.3 = {{ 10 % 4.3 }}
 33 "10.4" % 4 = {{ "10.4" % 4 }}
 34 
 35 Modulo by zero yields NaN:
 36 1 % 0 = {{ 1 % 0 }}
 37 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt