[Bug 37913] New: Inconsistent rounding behaviour for sprintf
wine-bugs at winehq.org
wine-bugs at winehq.org
Fri Jan 16 20:41:17 CST 2015
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 at winehq.org
Reporter: christopherwuy at 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.
More information about the wine-bugs
mailing list