I am concerned about the use of a double to store a Julian day number, given that the number is stored in binary floating point, not decimal.
The number of significant figures for a double in most systens today, assuming 8 byte doubles with IEEE encoding, is 15 significant figures. The Julian day number for today is 2453941, which takes 6 significant figures, leaving only 11 for the time of day down to microsecond granularity. The number of microseconds in one day is 86400,000,000 which is JUST enough (when I first noticed a double being used I was not if there would be enough). But there are some decimal numbers that do not have exact representations in binary (just like the number one third cannot be represented precisely as a decimal number even though it can be represented precisely in base 3).
I am still working on adding tests to the DateTime test harness. I cannot help wondering if I will be able to come up with some DateTimes that cannot be stored accurately.
I cannot help thinking that it would be better to store the integer part of the Julian day number in an integer and store the number of microseconds offset as a 64 bit integer.
-Andrew Marlow





