slovo/examples/i64-numeric-primitive.slo
2026-05-22 08:38:43 +02:00

38 lines
812 B
Plaintext

(module main)
(fn base () -> i64
2147483648i64)
(fn adjust ((value i64) (delta i64)) -> i64
(+ value delta))
(fn doubled ((value i64)) -> i64
(* value 2i64))
(fn local_total () -> i64
(let offset i64 -7i64)
(adjust (- (doubled (base)) 0i64) offset))
(fn high_enough ((value i64)) -> bool
(if (> value 4294967280i64)
(< value 4294967300i64)
false))
(fn exact_i64 () -> bool
(= (local_total) 4294967289i64))
(fn main () -> i32
(std.io.print_i64 (local_total))
(if (high_enough (local_total)) 0 1))
(test "i64 arithmetic returns exact fixture value"
(exact_i64))
(test "i64 comparison works in predicates"
(high_enough (local_total)))
(test "i64 division and ordering"
(if (>= (/ (local_total) 3i64) 1431655763i64)
(<= (/ (local_total) 3i64) 1431655763i64)
false))