[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of referenc

From: Gary E. Miller
Subject: Re: [gpsd-dev] [PATCH 3/3] Print offset in ntpshmmon instead of reference time
Date: Thu, 7 May 2015 15:02:03 -0700

Yo Miroslav!

> > -                    offset = (float(record[3]) - float(record[4]))
> > +                    offset = float(record[4])
> Python floats are 53 bits of precision.  The offset needs 62 bits of 
> precision.  So this discards the imporant parts of the offset.
> Take a look at this program to see how it fails:
>       test_timespec -v

My mistake, Python floats are only 52 bits of precision:

Run this program:

import numpy as np
for f in (np.float32, np.float64, float):
    finfo = np.finfo(f)
    print finfo.dtype, finfo.nexp, finfo.nmant

You get this result on Gentoo 64 bit:

float32 8 23
float64 11 52
float64 11 52

Run this program:

d = float("1431035819.123456789");

And you get:


Not acceptable.

Maybe you can try float128?

Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701
        address@hidden  Tel:+1(541)382-8588

reply via email to

[Prev in Thread] Current Thread [Next in Thread]