Subject: lib/3137: printf doesn't print sign of -0.0
To: None <gnats-bugs@gnats.netbsd.org>
From: Lennart Augustsson <augustss@cs.chalmers.se>
List: netbsd-bugs
Date: 01/25/1997 01:49:40
>Number:         3137
>Category:       lib
>Synopsis:       printf doesn't print sign of -0.0
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 24 17:05:01 1997
>Last-Modified:
>Originator:     Lennart Augustsson
>Organization:
Department of Computing Science, Chalmers University
>Release:        NetBSD-current 97-01-21
>Environment:
System: NetBSD calvin.cs.chalmers.se 1.2B NetBSD 1.2B (CALVIN) #70: Tue Jan 21 18:52:37 MET 1997 augustss@calvin.cs.chalmers.se:/usr/src/sys/arch/i386/compile/CALVIN i386


>Description:
	printf(3) does not print negative 0 with a minus sign.
	I don't know what POSIX has to say on this (if anything),
	but several other platforms do print it with a - sign.
>How-To-Repeat:
	Run this program.  As you can see x indeed has negative
	sign, but it is printed as a non-negative number.

#include <math.h>

main()
{
    double x = 0;
    x = -x;
    printf("%e %e\n", x, copysign(1.0, x));
}

>Fix:
	If we indeed want to print negative 0 with a sign I can make a fix.
>Audit-Trail:
>Unformatted: