sprite.box.width = @intFromFloat(@as(f32, sprite.texture.height) / @as(f32, sprite.texture.width) * @as(f32, sprite.box.height));
All of the values here are c_int. I am trying to convert everything to float to do math, but return another c_int. Why does it say "expected f32"??
src/main.zig:176:65: error: expected type 'f32', found 'c_int'
sprite.box.width = @intFromFloat(@as(f32, sprite.texture.height) / @as(f32, sprite.texture.width) * @as(f32, sprite.box.height));
~~~~~~~~~~~~~~^~~~~~~
I tried to test the same thing using some basic non struct values, and it works. What is going on? Why does it work below but not work above ??
pub fn main() void {
const a:c_int = 2;
const b:c_int = 3;
// works
const r:f32 = @as(f32, a) / @as(f32, b) * @as(f32, a);
std.debug.print("Hello, {d}!\n", .{r});
// works
const s:c_int = @intFromFloat(@as(f32, a) / @as(f32, b) * @as(f32, a));
std.debug.print("Hello, {d}!\n", .{s});
}