The documentation for the clang-tidy [bugprone-incorrect-roundings] check says:
The number 0.499999975 (smallest representable float number below 0.5) rounds to 1.0
As far as I can detect the smallest float number below 0.5 is 0.4999999702, not a 0.499999975. But despite of this, both numbers give me 0 values in naive rounding calculation:
#include <iostream>
int main() {
const float v1 = 0.499999975;
const float v2 = 0.4999999702;
std::cout << (int)(v1+0.5) << "\n"
<< (int)(v2+0.5) << "\n";
}
Am I missing something?
std::roundis way slower!