Dividing a span by a span #95
Answered
by
BurntSushi
SpookyYomo
asked this question in
Q&A
-
use jiff::{Span, SpanRound, ToSpan, Unit};
fn main() {
let dt1: Span = 5.nanoseconds();
let dt2: Span = 5.microseconds()
let y = 40_000 * dt1;
// let n = y / dt2; // error!
let squeeze_to_ns = SpanRound::new()
.smallest(Unit::Nanosecond)
.largest(Unit::Nanosecond);
// would be great to programatically determine the smaller of units between dt2 and y
let n = y.round(squeeze_to_ns).unwrap().get_nanoseconds()
/ x.round(squeeze_to_ns).unwrap().get_nanoseconds();
} Is this the best way so far? |
Beta Was this translation helpful? Give feedback.
Answered by
BurntSushi
Aug 13, 2024
Replies: 1 comment
-
That probably seems right, although it might be a little simpler with This might also be a good use case for |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
SpookyYomo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That probably seems right, although it might be a little simpler with
Span::total
.This might also be a good use case for
SignedDuration
, which is being added in #86.