1use ordered_float::NotNan;
2
3pub type Temperature = i8;
4pub type Standard = i8;
5pub type Absolute = u8;
6pub type Efficiency = f32;
7
8pub fn carnot_efficiency(one: Standard, other: Standard) -> Efficiency {
9 let one = to_absolute(one);
10 let other = to_absolute(other);
11 let one = unsafe { NotNan::new_unchecked(one as f32) };
12 let other = unsafe { NotNan::new_unchecked(other as f32) };
13 let (h, c) = if one > other {
14 (*one, *other)
15 } else {
16 (*other, *one)
17 };
18 1f32 - c / h
19}
20
21pub fn to_absolute(value: Standard) -> Absolute {
22 if value < 0 {
23 (value - i8::MIN) as u8
24 } else {
25 value as u8 + 128u8
26 }
27}