Skip to content
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

Need to specify Unix block end times explicitly #4

Closed
qntm opened this issue Nov 2, 2016 · 1 comment
Closed

Need to specify Unix block end times explicitly #4

qntm opened this issue Nov 2, 2016 · 1 comment
Assignees

Comments

@qntm
Copy link
Owner

qntm commented Nov 2, 2016

Same basic reasoning as for #2 and #3. For Unix block end times, we cannot just use the start of the next Unix block, as there is almost always an offset between the two. Irritatingly, the offset is not a neat number of Unix milliseconds but a neat number of often-slightly-shorter TAI milliseconds, which I suspect eventually yields the same 64-bit float but I won't know for sure until I've crunched the numbers...

@qntm qntm self-assigned this Nov 2, 2016
@qntm
Copy link
Owner Author

qntm commented Nov 3, 2016

I had some fun with arbitrary-precision calculators trying to figure out precisely where any given Unix block ends. The answers are:

1961-07-31 23:59:59.950000749999988750000168749997468750038
1962-01-01 00:00:00
1963-11-01 00:00:00.09999999870000001689999978030000285609996
1964-01-01 00:00:00
1964-04-01 00:00:00.099999998500000022499999662500005062499924
1964-09-01 00:00:00.099999998500000022499999662500005062499924
1965-01-01 00:00:00.099999998500000022499999662500005062499924
1965-03-01 00:00:00.099999998500000022499999662500005062499924
1965-07-01 00:00:00.099999998500000022499999662500005062499924
1965-09-01 00:00:00.099999998500000022499999662500005062499924
1966-01-01 00:00:00
1968-01-31 23:59:59.90000000299999991000000269999991900000243
1972-01-01 00:00:00.107757996767260096982197090534087283977381

(all UTC). Expressed as Unix millisecond counts, these are:

-265680000049.99999925000001124999983125000253124996
-252460800000
-194659199900.00000129999998310000021969999714390004
-189388800000
-181526399900.00000149999997750000033749999493750008
-168307199900.00000149999997750000033749999493750008
-157766399900.00000149999997750000033749999493750008
-152668799900.00000149999997750000033749999493750008
-142127999900.00000149999997750000033749999493750008
-136771199900.00000149999997750000033749999493750008
-126230400000
-60480000099.99999700000008999999730000008099999757
63072000107.757996767260096982197090534087283977381

The closest float to each of these numbers is:

-265680000050
-252460800000
-194659199900
-189388800000
-181526399900
-168307199900
-157766399900
-152668799900
-142127999900
-136771199900
-126230400000
-60480000100
63072000107.75799560546875

BUT what we actually want is the exact float or the next lowest float, which yields a different answer in several cases:

-265680000049.999969482421875
-252460800000
-194659199900
-189388800000
-181526399900
-168307199900
-157766399900
-152668799900
-142127999900
-136771199900
-126230400000
-60480000099.99999237060546875
63072000107.75800323486328125

We don't need to use all of those decimal places to uniquely identify those floats, so we can stop at:

-265680000049.99997
-252460800000
-194659199900
-189388800000
-181526399900
-168307199900
-157766399900
-152668799900
-142127999900
-136771199900
-126230400000
-60480000099.99999
63072000107.758

@qntm qntm closed this as completed Nov 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant