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

Sources/ucode/tests/custom/01_arithmetic/03_bitwise

  1 Ucode implements C-style bitwise operations. One detail is that these operations
  2 coerce their operands to 64bit integer values internally. If both operands are
  3 positive, unsigned 64bit semantics are used. If one of the operands is negative,
  4 both are converted to signed 64bit numbers.
  5 
  6 -- Expect stdout --
  7 Left shift:
  8 10 << 2 = 40
  9 3.3 << 4.1 = 48
 10 
 11 Right shift:
 12 10 >> 2 = 2
 13 3.3 >> 4.1 = 0
 14 
 15 Bitwise and:
 16 1234 & 200 = 192
 17 120.3 & 54.3 = 48
 18 
 19 Bitwise xor:
 20 1234 ^ 200 = 1050
 21 120.3 ^ 54.3 = 78
 22 
 23 Bitwise or:
 24 1234 | 200 = 1242
 25 120.3 | 54.3 = 126
 26 
 27 Complement:
 28 ~0 = 18446744073709551615
 29 ~10.4 = 18446744073709551605
 30 -- End --
 31 
 32 -- Testcase --
 33 Left shift:
 34 10 << 2 = {{ 10 << 2 }}
 35 3.3 << 4.1 = {{ 3.3 << 4.1 }}
 36 
 37 Right shift:
 38 10 >> 2 = {{ 10 >> 2 }}
 39 3.3 >> 4.1 = {{ 3.3 >> 4.1 }}
 40 
 41 Bitwise and:
 42 1234 & 200 = {{ 1234 & 200 }}
 43 120.3 & 54.3 = {{ 120.3 & 54.3 }}
 44 
 45 Bitwise xor:
 46 1234 ^ 200 = {{ 1234 ^ 200 }}
 47 120.3 ^ 54.3 = {{ 120.3 ^ 54.3 }}
 48 
 49 Bitwise or:
 50 1234 | 200 = {{ 1234 | 200 }}
 51 120.3 | 54.3 = {{ 120.3 | 54.3 }}
 52 
 53 Complement:
 54 ~0 = {{ ~0 }}
 55 ~10.4 = {{ ~10.4 }}
 56 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt