[time-nuts] arduino solar clock

Tom Van Baak tvb at LeapSecond.com
Sun Jan 19 19:47:40 EST 2014


> It is.  Both "double" and "float" are 32-bits.  Arduino uses the GCC AVR
> compiler.
> 
> If you care a lot about precision you use integer math and do all your
> calculations in integer units of milli or microseconds.  If you try to keep
> time in "floats" you are working with about four decimal digit
> approximations which might not be good enough.

Chris,

A double has 53 bits of precision (about 15.95 decimal digits), a float has 24 bits of precision (about 6.92 decimal digits).

The trick to answering your question is -- run the code on a PC, once using only doubles, once using only floats, and compare the results to see if precision is lost, or by how much.

In this case, the eot1.c code shows identical results in the ppm output (which was displayed with 0.1 ppm resolution). So I believe the code will work for Jim's Arduino without worry.

To push the envelope, if you change the tool to report frequency offsets to ppb or ppt resolution, then indeed there is a slight difference between calculating in double vs. single precision. The standard deviation of the equation of time is about 180 ppm. The difference between a full year of double calculations and a float calculations is about 0.0002 ppm rms. So for this code, the precision floor when using floats is 1.1e-6, or 5.9 digits.

/tvb



More information about the time-nuts mailing list