I am trying to translate the following C code to Zig using zig translate-c:
float float_test() {
return (float)(10.0f > 1.0f);
}
This results in the following Zig code:
pub export fn float_test() f32 {
return @as(f32, @floatFromInt(10.0 > 1.0));
}
Now since 10.0 > 1.0 produces a bool, trying to compile the generated code fails with error: expected integer type, found 'bool'. Could this possibly be a bug? Shouldn't the bool get casted into an integer before calling @floatFromInt, e. g. like this:
pub export fn float_test() f32 {
return @as(f32, @floatFromInt(@intFromBool(10.0 > 1.0)));
}