-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slightly inaccurate TAI block start times #2
Comments
Computing the "next float" in JavaScript is kind of difficult, but after crunching some numbers by hand, here's a full listing of the values which should be used:
|
qntm
added a commit
that referenced
this issue
Nov 2, 2016
As per issue #2. Will probably have to do the same for Unix block start times as per #3. And end times, in fact, since the Unix block end time *isn't* the same as the start time of the previous block... it's not even a precise number of Unix seconds offset, it's a precise number of *TAI* seconds offset!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The beginning of TAI for our purposes was 1961-01-01 00:00:01.422818000 TAI, which is -283996798577.182 TAI milliseconds.
t-a-i
calculates this figure internally asDate.UTC(1961, JANUARY, 1, 0, 0, 1, 422) + 0.818000
.However, strictly speaking, this figure cannot be represented exactly as a 64-bit IEEE 754 float. The number actually stored is the closest float to this value, which is -283996798577.1820068359375. This figure comes some 0.0000068359375 seconds before TAI began. This doesn't seem like a huge problem in the scheme of things, but if an instant in time is considered to be on the wrong side of one of these boundaries, then the wrong computation can be applied to it, and a visibly wrong result can come back. In this specific case, what should happen if we attempt to convert this value to Unix time is that an exception should be thrown, because it is too early. What actually happens is that the conversion is carried out with no problems!
Around half of the figures used for TAI block start points prior to 1972 are faulty in this way.
Instead of storing the closest 64-bit float to the beginning of a TAI block, we should store the next lowest available 64-bit float. In this case, the next float is -283996798577.18194580078125, which comes 0.00005419921875 seconds after TAI began. Not all of those decimal places are necessary, the smallest unambiguous representation for JavaScript's purposes is -283996798577.18195.
It is probably also a good idea to use these values explicitly rather than computing them using
Date.UTC()
and adding a fraction on.The text was updated successfully, but these errors were encountered: