Closed
Description
I know floats aren't exactly known for their precision and i might be missing something.
But i'm seeing some odd platform dependent behavior when i combine a f32
float division with .tan()
This code run on mac, linux and windows
let floaty: f32 = 1.22222; // 5 decimal points
println!("{:.32}", floaty);
println!("{:.32}", floaty / 2.0);
println!("{:.32}", (floaty / 2.0).tan());
Gives the following printout
// mac
1.22221994400024414062500000000000
0.61110997200012207031250000000000
0.70057231187820434570312500000000
// linux
1.22221994400024414062500000000000
0.61110997200012207031250000000000
0.70057231187820434570312500000000
// windows
1.22221994400024414062500000000000
0.61110997200012207031250000000000
0.70057231187820434570312500000000
All the outputs are the same as i guess is expected.
Now i add one more decimal
let floaty: f32 = 1.222222; // 6 decimal points
println!("{:.32}", floaty);
println!("{:.32}", floaty / 2.0);
println!("{:.32}", (floaty / 2.0).tan());
Which outputs
// mac & linux
1.22222197055816650390625000000000
0.61111098527908325195312500000000
0.70057380199432373046875000000000
// windows
1.22222197055816650390625000000000
0.61111098527908325195312500000000
0.70057386159896850585937500000000
Now windows suddenly shows a different output on the last line.
I have testet this on my windows 10 pc, linux laptop (mint) and a github actions matrix of ubuntu, windows, mac, nightly, beta and stable.
Is this a bug or am i missing something?