Subject: Re: bin/36831: rtclocaltime shows negative 0
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, zafer@aydogan.de>
From: Alan Barrett <apb@cequrux.com>
List: netbsd-bugs
Date: 08/25/2007 07:20:03
The following reply was made to PR bin/36831; it has been noted by GNATS.
From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc: netbsd-bugs@NetBSD.org
Subject: Re: bin/36831: rtclocaltime shows negative 0
Date: Sat, 25 Aug 2007 09:16:06 +0200
On Fri, 24 Aug 2007, Alan Barrett wrote:
> This is caused by an awk bug, which is reproducible like this:
>
> echo foo | awk '{print (-1 * 0)}'
> # prints "-0"; should print "0".
I am no longer convinced that awk's behaviour is incorrect; see a
message from Terry Moore to tech-userlevel@netbsd.org dated 24 Aug
2007, in which he points out that the C standard requires printf to
distinguish between positive and negative zero:
According to ISO C-1999 page 275, section 7.19.6.1, note 233:
"The results of all floating conversions of a negative zero, and of
negative values that round to zero, include a minus sign".
> > The patch fixes this. No functional changes, just cosmetics showing 0
> > without a negative sign.
>
> Your patch happens to work around the awk bug, but makes the shell script
> much harder to understand.
I implemented a different fix, which also avoids creating a negative
zero result, but which I find easier to read.
--apb (Alan Barrett)