diff --git a/src/math/scalar.rs b/src/math/scalar.rs index f350cf990..72a1df265 100644 --- a/src/math/scalar.rs +++ b/src/math/scalar.rs @@ -24,7 +24,12 @@ impl Scalar { /// Construct a `Scalar` from an `f64` pub fn from_f64(scalar: f64) -> Self { - Self(scalar) + if scalar.is_finite() { + // `scalar` is neither infinite, nor NaN + Self(scalar) + } else { + panic!("Invalid scalar value: {scalar}"); + } } /// Construct a `Scalar` from a `u64`