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

Add NTP64::as_secs_f64() #13

Merged
merged 3 commits into from
Sep 15, 2023
Merged

Add NTP64::as_secs_f64() #13

merged 3 commits into from
Sep 15, 2023

Conversation

JEnoch
Copy link
Member

@JEnoch JEnoch commented Sep 15, 2023

Add a NTP64::as_secs_f64() operation.

This avoids going through .to_system_time().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs_f64(), also preventing approximations that made resulting f64 not comparables.

The decimal part of the f64 is the result of a division of NTP64's Fraction part by 2^32.
As a consequence, the even if resulting f64 seems to have a precision lower than 1 nanosecond, that's not the case. It still has the precision of the time source (3.5 nanosecond if generated by HLC).

@JEnoch JEnoch merged commit 3edd8a2 into master Sep 15, 2023
4 checks passed
@JEnoch JEnoch deleted the ntp64_as_secs_f64 branch September 15, 2023 15:00
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

Successfully merging this pull request may close these issues.

2 participants