[Bug 37913] New: Inconsistent rounding behaviour for sprintf
https://bugs.winehq.org/show_bug.cgi?id=37913 Bug ID: 37913 Summary: Inconsistent rounding behaviour for sprintf Product: Wine Version: unspecified Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcp Assignee: wine-bugs(a)winehq.org Reporter: christopherwuy(a)gmail.com Distribution: --- sample source code and output demonstrating the problem: #include <iostream> #include <stdio.h> using namespace std; int main() { double a; a = 3.5; char *tmp = new char(100); char fmt[18] = " is %.0f"; sprintf(tmp, fmt, a); cout<<endl<<a<<tmp<<endl<<endl; a = -4.5; sprintf(tmp, fmt, a); cout<<endl<<a<<tmp<<endl<<endl; a = -0.5; sprintf(tmp, fmt, a); cout<<endl<<a<<tmp<<endl<<endl; a = 2597.625; printf("%.3f", a); sprintf(tmp, " is %.2lf", a); cout<<tmp<<endl<<endl; } This code running by wine 's Output is: 3.5 is 4 -4.5 is -4 -0.5 is -0 2597.625 is 2597.62 while windows' output is: 3.5 is 4 -4.5 is -5 -0.5 is -1 2597.625 is 2597.63 It indicated that Wine's sprintf used rounding rule which is Round half to even, while windows used Round half away from zero. You can find a detailed discussion of 'similar bug' form https://sourceware.org/bugzilla/show_bug.cgi?id=4943 -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37913 christopherwuy(a)gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |christopherwuy(a)gmail.com, | |piotr(a)codeweavers.com -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37913 tiago <tiagoaparecido007(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tiagoaparecido007(a)gmail.com -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37913 Piotr Caban <piotr.caban(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |piotr.caban(a)gmail.com Component|msvcp |msvcrt -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37913 Gijs Vermeulen <gijsvrm(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Version|unspecified |1.7.34 Ever confirmed|0 |1 --- Comment #1 from Gijs Vermeulen <gijsvrm(a)gmail.com> --- Still present with wine-5.14, results are still the same on both Wine and Windows. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37913 --- Comment #2 from Piotr Caban <piotr.caban(a)gmail.com> --- (In reply to Gijs Vermeulen from comment #1)
Still present with wine-5.14, results are still the same on both Wine and Windows.
The bug should be already fixed. Please retest in wine 5.15 (it works for me with current wine, I didn't check when it was fixed exactly but I'm expecting that it was already working correctly in wine-5.14). Please also note that the output on windows changed when newest ucrtbase is used. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37913 --- Comment #3 from Gijs Vermeulen <gijsvrm(a)gmail.com> --- (In reply to Piotr Caban from comment #2)
The bug should be already fixed. Please retest in wine 5.15 (it works for me with current wine, I didn't check when it was fixed exactly but I'm expecting that it was already working correctly in wine-5.14). Please also note that the output on windows changed when newest ucrtbase is used.
Gijss-MacBook-Pro:Desktop gverm$ x86_64-w64-mingw32-g++ -static sprintf.cpp Gijss-MacBook-Pro:Desktop gverm$ $WINE a.exe 3.5 is 4 -4.5 is -4 -0.5 is -0 2597.625 is 2597.62 These are the steps I used and result I got with wine-5.15. If this is the expected result, this bug can be resolved. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37913 Piotr Caban <piotr.caban(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED Fixed by SHA1| |1bc6f0c86174cf1b5e47f1f1324 | |a3f733e0658a1 --- Comment #4 from Piotr Caban <piotr.caban(a)gmail.com> --- You're not using wine sprintf implementation when the test is compiled this way. You can see that it works by changing "cout<<..." lines with printf and compiling without -static switch. Marking the bug as fixed. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=37913 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #5 from Alexandre Julliard <julliard(a)winehq.org> --- Closing bugs fixed in 5.16. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (2)
-
wine-bugs@winehq.org -
WineHQ Bugzilla