GNU GCC does not round floating-point divisions to the nearest value
I believe the issue is that some of this ends up evaluated at compile-time, and the compiler really has no idea how to do rounding correctly at that point. When implementing floating point tests for an x86 emulator, we had to create a macro that would ensure that the calculation was done at runtime rather than at compile time for this exact reason: <a href="https://github.com/ish-app/ish/blob/18176b6931d69bdabe48f137e48d8e8118c22122/emu/float80-test.c#L11" rel="nofollow">https://github.com/ish-app/ish/blob/18176b6931d69bdabe48f137...</a>. If anyone knows how to control floating point rounding in C reliably, I'd be interesting in hearing it :)