Subject: Re: bin/36831: rtclocaltime shows negative 0
To: None <>
From: Alan Barrett <>
List: netbsd-bugs
Date: 08/25/2007 09:16:06
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 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, 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)