22 lines
509 B
Rust
22 lines
509 B
Rust
use numfmt::{Formatter, Precision};
|
|
|
|
pub fn format_frequency(freq: f64) -> String {
|
|
let mut formatter = Formatter::new()
|
|
.separator(' ')
|
|
.unwrap()
|
|
.precision(Precision::Decimals(0));
|
|
|
|
formatter.fmt2(freq).to_owned()
|
|
}
|
|
|
|
pub fn format_frequency_mhz(freq: f64) -> String {
|
|
let mut formatter = Formatter::new()
|
|
.separator(' ')
|
|
.unwrap()
|
|
.suffix(" Hz")
|
|
.unwrap()
|
|
.precision(Precision::Decimals(3));
|
|
|
|
formatter.fmt2(freq).to_owned()
|
|
}
|