slovo/tests/numeric-widening-conversions.surface.lower
2026-05-22 08:38:43 +02:00

46 lines
923 B
Plaintext

program main
fn base_i64() -> i64
call std.num.i32_to_i64
int 2147483647
fn widened_i64() -> i64
binary +
call base_i64
i64 1
fn half_step() -> f64
binary +
call std.num.i32_to_f64
int 5
float 0.5
fn wide_as_f64() -> f64
call std.num.i64_to_f64
call widened_i64
fn main() -> i32
call std.io.print_i64
call widened_i64
call std.io.print_f64
call wide_as_f64
if
binary =
call widened_i64
i64 2147483648
int 0
int 1
test "i32 widens to i64"
binary =
call std.num.i32_to_i64
int 42
i64 42
test "i32 to i64 feeds i64 arithmetic"
binary =
call widened_i64
i64 2147483648
test "i32 widens to f64"
binary =
call std.num.i32_to_f64
int 42
float 42
test "i64 widens to f64"
binary =
call wide_as_f64
float 2147483648