From 2005b7d5cac0d49b5d89a78186b6445a0f4a31e2 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Sat, 9 Dec 2023 18:26:59 +0100 Subject: [PATCH] [clippy] u64 -> f64 conversion is precision loss --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index 928af1d..7a97081 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,14 @@ fn count_prime_factor_exponent(prime: u64, mut nr: u64) -> u64 { fn prime_factors(nr: u64, primes: &[u64]) -> u64 { let mut num_teilers = 1; + // safety: nr <= 2.pow(53) must be fulfilled, + // otherwise we have a precision loss + assert!(nr <= 2u64.pow(53)); + #[allow( + clippy::cast_sign_loss, + clippy::cast_possible_truncation, + clippy::cast_precision_loss + )] let nr_sqrt = (nr as f64).sqrt().ceil() as u64; for prime in primes {