// Int arithmetic at its edges: the native fast paths (louise_rt.h) must agree // with the interpreter (issue #61). import std/io fn cmp :: a: Int b: Int -> String { match compare a b { Lt -> "lt", Eq -> "eq", Gt -> "gt" } } pub fn main :: -> () / { let big = 4611686018427387903 let small = 0 - big - 1 io.println ( show (7 / 2) <> " " <> show (0 - 7 / 2) <> " " <> show ((0 - 7) / 2) <> " " <> show (7 / (0 - 2)) ) io.println ( show (7 % 3) <> " " <> show ((0 - 7) % 3) <> " " <> show (7 % (0 - 3)) <> " " <> show (small % (0 - 1)) ) io.println ( show (big * 1) <> " " <> show (small * 1) <> " " <> show (1073741824 * 1073741823) <> " " <> show ((0 - 3) * 5) ) io.println (show (small / 2) <> " " <> show (big / (0 - 1))) io.println ( cmp small big <> " " <> cmp big big <> " " <> cmp 0 (0 - 1) <> " " <> show (small == small) <> " " <> show (small == big) ) let zero = big - big io.println (show (1 / zero)) } //> 3 -3 -3 -3 //> 1 -1 1 0 //> 4611686018427387903 -4611686018427387904 1152921503533105152 -15 //> -2305843009213693952 -4611686018427387903 //> lt eq gt True False //! panic: division by zero