You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hmm on further investigation, this may be due to the nanosecond rounding more than the +1
chachi
changed the title
+1 in conversion from Duration means it's not round-trip equivalent
Timestamp is not round-trip equivalent with Display and parse()
Jun 24, 2024
The Display trait and thus the ToString trait convert the NTP64 to a RFC3339 representation to be more "human readable".
As the last 32 bits of a NTP64 is the fraction of 1 second, converting this fraction to any subdivision of the second requires to make a division by 2^32. This means that 1u64 as NTP64 represents approximately 0,232830644 nanoseconds.
Thus converting a NTP64 to string and then back to NTP64 will give back the same number in only for ~23,28% of the numbers.
e.g. this test succeeds:
The
+ 1
at the end of theimpl From<Duration>
breaks stringifying and then parsing the same number back out.uhlc-rs/src/ntp64.rs
Line 231 in 68bf159
The following test fails:
The text was updated successfully, but these errors were encountered: