ReviewOS

also looking at this

home-lang/home

fix(interpreter): keep 2^63 as a float in floor, ceil and round

#932
Open mkantautas wants to merge fix/interpreter-floor-ceil-round-max into main
2 files +22 -3
packages/interpreter/tests/program_eval_test.zigmodified+17-0
Changes to packages/interpreter/tests/program_eval_test.zig
@@ -46,6 +46,23 @@ test "eval: print a string literal (hello world)" {
4646 );
4747}
4848
49test "eval: floor, ceil and round keep 2^63 as a float" {
50 try runProgram(
51 \\fn main() {
52 \\ let max = 9223372036854775807.0
53 \\ assert(is_float(floor(max)))
54 \\ assert(is_float(ceil(max)))
55 \\ assert(is_float(round(max)))
56 \\ assert(is_int(floor(9223372036854774784.0)))
57 \\ assert(floor(9223372036854774784.0) == 9223372036854774784)
58 \\ assert(is_int(ceil(-9223372036854775808.0)))
59 \\ assert(ceil(-9223372036854775808.0) == -9223372036854775807 - 1)
60 \\ assert(is_int(round(2.5)))
61 \\ assert(round(2.5) == 3)
62 \\}
63 );
64}
65
4966test "eval: let-binding then use" {
5067 try runProgram(
5168 \\fn main() {