[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] Bug found in unix_to_iso8601()
From: |
Gary E. Miller |
Subject: |
Re: [gpsd-dev] Bug found in unix_to_iso8601() |
Date: |
Thu, 8 Nov 2018 13:58:34 -0800 |
Yo Peter!
On Thu, 08 Nov 2018 21:43:38 +0000 (GMT)
Peter Liu <address@hidden> wrote:
> I found this bug but I will not be able to submit patches any time
> soon.
Bug reports are good.
> Could someone please take a quick look at the following in gpsutil.c?
> There should be a trivial fix.
>
> (void)snprintf(fractstr, sizeof(fractstr), "%.3f", fractional);
>
>
> If the fractional part is 0.9995 or larger, it is rounded up and
> tractstr returns "1.000". It is not ".999".
I thought snprintf("%f") truncated, not rounded up.
> The end result is that with fixtime=1541766896.999512,
> unix_to_iso8601() produces "2018-11-09T12:34:56.000Z" instead of
> "2018-11-09T12:34:57.000Z". We lost one whole second.
You have seen this? If so, can you provide that as a test case?
I'll add a test case for this right now.
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
address@hidden Tel:+1 541 382 8588
Veritas liberabit vos. -- Quid est veritas?
"If you can’t measure it, you can’t improve it." - Lord Kelvin
pgpfdWqZp1KRB.pgp
Description: OpenPGP digital signature