Date: Mon, 24 Nov 1997 20:01:52 +1100 From: Bruce Evans <bde@zeta.org.au> To: cagney@tpgi.com.au, freebsd-bugs@FreeBSD.ORG, joerg@FreeBSD.ORG Subject: Re: bin/5135 Message-ID: <199711240901.UAA06647@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>Synopsis: scanf accepts %Lg but treates it as %g > >State-Changed-From-To: open-closed >State-Changed-By: joerg >State-Changed-When: Mon Nov 24 08:49:18 MET 1997 >State-Changed-Why: > >Fixed by Bruce in rev 1.12 of src/lib/libc/stdio/vfscanf.c a couple of >days ago (also merged to 2.2-stable). I even reported it to bug-gdb. Of course, the simple fix of reading long doubles as doubles doesn't actually work if the input has more than double precision or is too large for a double. The corresponding simplistic conversions for printf causes more problems: --- #include <stdio.h> main() { fprintf(stderr, "%.20Lg\n", 12345678901234567890.0L); fprintf(stderr, "%.20Lg\n", 12345678901234567890.0e1234L); } --- Here the first printf loses precision and the second printf causes SIGFPE for overflow (unless overflow exceptions are masked; then then it loses precision and the result is "Inf"). Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199711240901.UAA06647>