Date: Tue, 20 Aug 2002 10:32:55 -0700 (PDT) From: GOTO Kentaro <gotoken@notwork.org> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/41823: printf("%+f\n", -0.0) generates +0.000000 Message-ID: <200208201732.g7KHWtKV034152@www.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 41823 >Category: bin >Synopsis: printf("%+f\n", -0.0) generates +0.000000 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Aug 20 10:40:28 PDT 2002 >Closed-Date: >Last-Modified: >Originator: GOTO Kentaro >Release: STABLE and CURRENT >Organization: >Environment: FreeBSD 5.0-CURRENT i386 >Description: vfprintf() generates a wrong "+" sign for a floating point number minus zero, i.e., -0.0, when +[eEfgG] is specified in the format. >How-To-Repeat: % echo 'main(){printf("%+f\\n", -0.0);}' | /usr/bin/cc -xc - && ./a.out +0.000000 >Fix: How about Checking sign bit instead of `< 0'. For example, NetBSD's /usr/src/lib/libc/stdio/vfprintf.c:cvt() does digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve); if (dsgn) { value = -value; *sign = '-'; } else *sign = '\000'; But FreeBSD's does if (value < 0) { value = -value; *sign = '-'; } else *sign = '\000'; This test does not work in this case because IEEE754 defines the truth value of -ZERO < ZERO as FALSE. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208201732.g7KHWtKV034152>