Zig Version
0.17.0-dev.1282+c0f9b51d8
Steps to Reproduce, Observed Behavior, and Expected Behavior
conststd=@import("std");pubfnmain()!void{varx:f64=12.3456;constfraction:f32=@floatCast(x/100);x=@round(fraction*10000)/100;std.debug.print("bug: not rounded {d}\n",.{x});x=@round(fraction*10000);x=x/100;std.debug.print("rounded {d}\n",.{x});std.debug.print("also rounded {d}\n",.{@round(fraction*10000)/100});}
Produces this output:
bug: not rounded 12.350000381469727
rounded 12.35
also rounded 12.35
Expected behavior is for all output to be 12.35
This seems specific to @round on an f32 in a compound expression into a f64 destination.
It reproduces for me on:
- linux x86_64 selfhosted
- linux x86_64 llvm
- macos aarch64 llvm
### Zig Version
0.17.0-dev.1282+c0f9b51d8
### Steps to Reproduce, Observed Behavior, and Expected Behavior
```zig
const std = @import("std");
pub fn main() !void {
var x: f64 = 12.3456;
const fraction: f32 = @floatCast(x / 100);
x = @round(fraction * 10000) / 100;
std.debug.print("bug: not rounded {d}\n", .{x});
x = @round(fraction * 10000);
x = x / 100;
std.debug.print("rounded {d}\n", .{x});
std.debug.print("also rounded {d}\n", .{@round(fraction * 10000) / 100});
}
```
Produces this output:
```
bug: not rounded 12.350000381469727
rounded 12.35
also rounded 12.35
```
Expected behavior is for all output to be `12.35`
This seems specific to `@round` on an f32 in a compound expression into a f64 destination.
It reproduces for me on:
* linux x86_64 selfhosted
* linux x86_64 llvm
* macos aarch64 llvm