From: SourceForge.net <no...@so...> - 2003-04-22 18:57:04
|
Bugs item #724385, was opened at 2003-04-19 21:49 Message generated for change (Comment added) made by jbannon You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=724385&group_id=2435 Category: gcc Group: None Status: Open Resolution: None Priority: 5 Submitted By: Darrin Forelle (darrinf) Assigned to: Danny Smith (dannysmith) Summary: strtold bug Initial Comment: The following code produce wrong result: #include <stdio.h> #include <stdlib.h> int main() { char *strval = "0.876190625"; printf("\%s\ -> %Lg", strval, strtold(strval, 0)); return 0; } MinGW is v2.0.0 with runtime v2.4. The result is the same with gcc v3.2(mingw special 20020817-1) and v3.2.2(mingw special 20030208-1). ---------------------------------------------------------------------- Comment By: James Bannon (jbannon) Date: 2003-04-22 18:57 Message: Logged In: YES user_id=734384 I tried it with double and it behaved as expected. I recognised it when it rounded to get rid of the 2 least-significant digits. ---------------------------------------------------------------------- Comment By: Luke Dunstan (infidel) Date: 2003-04-22 02:15 Message: Logged In: YES user_id=30442 Recent versions of MinGW GCC use 80-bit long doubles and 64-bit doubles, while MSVC and therefore the C runtime library use both 64-bit doubles and long doubles. The only way that your code will work is if MSVCRT printf is replaced with a version of printf that handles 80-bit long doubles. Until then, the workaround is to just use a double instead of a long double for displaying output. ---------------------------------------------------------------------- Comment By: James Bannon (jbannon) Date: 2003-04-20 08:58 Message: Logged In: YES user_id=734384 James Bannon April 20, 2003 Tried it with both compiler sets and got the wrong results. The default Dev-C++ compiler also produced the same result. Tried it also with 0.0 and this was correct, but any other value seemed to be wildly inaccurate. Also tried the wchar_t versions with the same results. Tried changing the types to match the prototypes exactly but this made no difference. I haven't tried the Cygwin distribution as yet. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=724385&group_id=2435 |