Allow relative speed of -0.0 (#7740)

# Objective

-0.0 should typically be treated exactly the same as 0.0, but this assertion was rejecting it while allowing 0.0. The `Duration` API handles this correctly (on recent Rust versions) and returns a zero `Duration` for both -0.0 and 0.0.

## Solution

Check for `ratio >= 0.0`, which is true if `ratio` is `-0.0`.

---

## Changelog

Allow relative speed of -0.0 in the `Time::set_relative_speed_fXX` methods.
This commit is contained in:
Sludge 2023-02-18 22:43:08 +00:00
parent 67a89e9c58
commit 104c74c3bc

View file

@ -399,7 +399,7 @@ impl Time {
#[inline]
pub fn set_relative_speed_f64(&mut self, ratio: f64) {
assert!(ratio.is_finite(), "tried to go infinitely fast");
assert!(ratio.is_sign_positive(), "tried to go back in time");
assert!(ratio >= 0.0, "tried to go back in time");
self.relative_speed = ratio;
}