You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current Universal C runtime on the website seems to still have the "round away from zero" bug. The IEEE standard since 1985 has been to "round to nearest even" or "banker's rounding" which reduces bias across aggregate calculations.
We only just noticed this bug at my office. The following C++ code on x64/x86 exhibits the issue, as it is part of the crt, not the compiler:
#include
int main () {
char str[30];
sprintf(str, "%.0lf", 2.5);
std::cout << str;
}
The output should be "2" but is still giving "3". I think this update is part of 21H2 but don't quote me on it. I have yet to find the change log.
Steps to reproduce
#include
// Type your code here, or load an example.
int main () {
char str[30];
sprintf(str, "%.0lf", 2.5);
std::cout << str;
}
Expected behavior
Output: 2
Reproduction link
Not applicable
Screenshots
Not applicable
Operating System
Windows 10
Browser version
Firefox 99.01
The text was updated successfully, but these errors were encountered:
Describe the bug
The current Universal C runtime on the website seems to still have the "round away from zero" bug. The IEEE standard since 1985 has been to "round to nearest even" or "banker's rounding" which reduces bias across aggregate calculations.
We only just noticed this bug at my office. The following C++ code on x64/x86 exhibits the issue, as it is part of the crt, not the compiler:
#include
int main () {
char str[30];
sprintf(str, "%.0lf", 2.5);
std::cout << str;
}
The output should be "2" but is still giving "3". I think this update is part of 21H2 but don't quote me on it. I have yet to find the change log.
Steps to reproduce
#include
// Type your code here, or load an example.
int main () {
char str[30];
sprintf(str, "%.0lf", 2.5);
std::cout << str;
}
Expected behavior
Output: 2
Reproduction link
Not applicable
Screenshots
Not applicable
Operating System
Windows 10
Browser version
Firefox 99.01
The text was updated successfully, but these errors were encountered: