#![allow(clippy::arithmetic_side_effects)]
pub const KELVINS_PER_RLO: u64 = 1_000_000_000;
pub fn kelvins_to_rlo(kelvins: u64) -> f64 {
kelvins as f64 / KELVINS_PER_RLO as f64
}
pub fn rlo_to_kelvins(rlo: f64) -> u64 {
(rlo * KELVINS_PER_RLO as f64) as u64
}
use std::fmt::{Debug, Display, Formatter, Result};
pub struct Rlo(pub u64);
impl Rlo {
fn write_in_rlo(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"◎{}.{:09}",
self.0 / KELVINS_PER_RLO,
self.0 % KELVINS_PER_RLO
)
}
}
impl Display for Rlo {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
self.write_in_rlo(f)
}
}
impl Debug for Rlo {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
self.write_in_rlo(f)
}
}