get rid of to_f64
reason: faulty and unneeded
This commit is contained in:
parent
55ffd09fe5
commit
f125145690
14
src/main.rs
14
src/main.rs
@ -17,9 +17,6 @@ use std::{
|
|||||||
time::SystemTime,
|
time::SystemTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use thread_priority::{set_current_thread_priority, ThreadPriority};
|
|
||||||
|
|
||||||
fn p(n: f64) -> f64 {
|
fn p(n: f64) -> f64 {
|
||||||
let ln_n = n.ln();
|
let ln_n = n.ln();
|
||||||
let ln_ln_n = ln_n.ln();
|
let ln_ln_n = ln_n.ln();
|
||||||
@ -39,12 +36,10 @@ fn to_usize(f: f64) -> usize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_f64(u: usize) -> f64 {
|
|
||||||
f64::from_bits(u as u64)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
fn try_set_thread_priority() {
|
fn try_set_thread_priority() {
|
||||||
|
use thread_priority::{set_current_thread_priority, ThreadPriority};
|
||||||
|
|
||||||
if let Err(e) = set_current_thread_priority(ThreadPriority::Max) {
|
if let Err(e) = set_current_thread_priority(ThreadPriority::Max) {
|
||||||
eprintln!("[WARN] failed to set thread priority to max");
|
eprintln!("[WARN] failed to set thread priority to max");
|
||||||
eprintln!("{e}");
|
eprintln!("{e}");
|
||||||
@ -198,10 +193,7 @@ fn main() {
|
|||||||
|
|
||||||
assert_eq!(primes.len(), NU);
|
assert_eq!(primes.len(), NU);
|
||||||
|
|
||||||
println!(
|
println!("primes added: {added} | removed: {removed}");
|
||||||
"primes added: {added} | % added: {}% | removed: {removed}",
|
|
||||||
to_f64(added) / to_f64(primes.len()) * 100.0
|
|
||||||
);
|
|
||||||
println!("time: {difference:?}");
|
println!("time: {difference:?}");
|
||||||
println!("writing primes...");
|
println!("writing primes...");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user