I'm trying to cast to float by calling @as on my variable, this works correctly if the variable is constant, but throws a compile error otherwise. How to correctly perform casting from int to float in zig?
pub fn main() void {
var foo: u32 = 3;
const bar: f32 = @as(f32, foo) / 5;
foo = 42;
std.debug.print("{d}", .{bar});
}
error: expected type 'f32', found 'u32'
const bar: f32 = @as(f32, foo) / 5;
^~~