Skip to content

Commit

Permalink
impl Ieee64::from(f64) and Ieee32::from(f32)
Browse files Browse the repository at this point in the history
  • Loading branch information
mokeyish authored and sunfishcode committed Feb 19, 2019
1 parent 50c66ae commit 2f61600
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cranelift-codegen/src/ir/immediates.rs
Expand Up @@ -665,6 +665,12 @@ impl FromStr for Ieee32 {
}
}

impl From<f32> for Ieee32 {
fn from(x: f32) -> Self {
Ieee32::with_float(x)
}
}

impl Ieee64 {
/// Create a new `Ieee64` containing the bits of `x`.
pub fn with_bits(x: u64) -> Self {
Expand Down Expand Up @@ -726,6 +732,12 @@ impl FromStr for Ieee64 {
}
}

impl From<f64> for Ieee64 {
fn from(x: f64) -> Self {
Ieee64::with_float(x)
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 2f61600

Please sign in to comment.