F8->f32 conversion
This commit is contained in:
parent
5193b1c5b9
commit
7ea2d49d3d
10
src/lib.rs
10
src/lib.rs
|
|
@ -65,6 +65,16 @@ impl From<F8> for u8 {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<F8> for f32 {
|
||||
fn from(value: F8) -> Self {
|
||||
if value.0 == 0 {
|
||||
return 0.0;
|
||||
}
|
||||
let (m, e) = value.split_unbias();
|
||||
(m as f32) * (e as f32).exp2()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user