[Bug 28422] scanf family of functions provides only 7 digits of precision for converting doubles and long doubles

wine-bugs at winehq.org wine-bugs at winehq.org
Sat Nov 3 04:46:28 CDT 2012


http://bugs.winehq.org/show_bug.cgi?id=28422

--- Comment #9 from Piotr Caban <piotr.caban at gmail.com> 2012-11-03 04:46:28 CDT ---
Comparison of random double values generated with current wine and by the patch
attached to first comment. First value is the string that is to be parsed,
second - value produced by wine, third - value created by compiler, fourth -
relative error. All doubles are printed with wine, the printing may be
inaccurate.

Code to generate it is following:
        double d;

#define do_test(x) \
        sscanf(#x, "%lf", &d); \
        printf(#x ": %.20le, expected %.20le, error %le\n", d, x, (d>x ? d-x :
x-d)/x);

        do_test(1.1e-30);
        do_test(1.13e70);
        do_test(121.526289132948123985293528931983849135);
        do_test(13984138953925742759247952497597232972794298.2139812983);
        do_test(0.1);
        do_test(7.0);

Implementation attached to first comment:
1.1e-30: 1.10000000000000009167e-030, expected 1.09999999999999991651e-030,
error 1.592385e-016
1.13e70: 1.13000000000000019690e+070, expected 1.13000000000000004365e+070,
error 1.356191e-016
121.526289132948123985293528931983849135: 1.21526289132948107863e+002, expected
1.21526289132948122074e+002, error 1.169365e-016
13984138953925742759247952497597232972794298.2139812983:
1.39841389539257487979e+043, expected 1.39841389539257438462e+043, error
3.540983e-016
0.1: 1.00000000000000005551e-001, expected 1.00000000000000005551e-001, error
0.000000e+000
7.0: 7.00000000000000000000e+000, expected 7.00000000000000000000e+000, error
0.000000e+000

Current wine:
1.1e-30: 1.10000000000000009167e-030, expected 1.09999999999999991651e-030,
error 1.592385e-016
1.13e70: 1.13000000000000019690e+070, expected 1.13000000000000004365e+070,
error 1.356191e-016
121.526289132948123985293528931983849135: 1.21526289132948136285e+002, expected
1.21526289132948122074e+002, error 1.169365e-016
13984138953925742759247952497597232972794298.2139812983:
1.39841389539257413703e+043, expected 1.39841389539257438462e+043, error
1.770492e-016
0.1: 1.00000000000000005551e-001, expected 1.00000000000000005551e-001, error
0.000000e+000
7.0: 7.00000000000000000000e+000, expected 7.00000000000000000000e+000, error
0.000000e+000

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
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