1# test arithmetic operators 2 3 4@micropython.viper 5def add(x: int, y: int): 6 print(x + y) 7 print(y + x) 8 9 10add(1, 2) 11add(42, 3) 12add(-1, 2) 13add(-42, -3) 14 15 16@micropython.viper 17def sub(x: int, y: int): 18 print(x - y) 19 print(y - x) 20 21 22sub(1, 2) 23sub(42, 3) 24sub(-1, 2) 25sub(-42, -3) 26 27 28@micropython.viper 29def mul(x: int, y: int): 30 print(x * y) 31 print(y * x) 32 33 34mul(0, 1) 35mul(1, -1) 36mul(1, 2) 37mul(8, 3) 38mul(-3, 4) 39mul(-9, -6) 40 41 42@micropython.viper 43def shl(x: int, y: int): 44 print(x << y) 45 46 47shl(1, 0) 48shl(1, 3) 49shl(1, 30) 50shl(42, 10) 51shl(-42, 10) 52 53 54@micropython.viper 55def shr(x: int, y: int): 56 print(x >> y) 57 58 59shr(1, 0) 60shr(1, 3) 61shr(42, 2) 62shr(-42, 2) 63 64 65@micropython.viper 66def and_(x: int, y: int): 67 print(x & y, y & x) 68 69 70and_(1, 0) 71and_(1, 3) 72and_(0xF0, 0x3F) 73and_(-42, 6) 74 75 76@micropython.viper 77def or_(x: int, y: int): 78 print(x | y, y | x) 79 80 81or_(1, 0) 82or_(1, 2) 83or_(-42, 5) 84 85 86@micropython.viper 87def xor(x: int, y: int): 88 print(x ^ y, y ^ x) 89 90 91xor(1, 0) 92xor(1, 2) 93xor(-42, 5) 94