Use ldexp from cmath instead

This commit is contained in:
Christian Poveda 2019-08-08 15:22:34 -05:00
parent 7143ccc8fa
commit e1d1cd191f

View File

@ -594,8 +594,10 @@ fn emulate_foreign_item(
// FIXME: Using host floats.
let x = f64::from_bits(this.read_scalar(args[0])?.to_u64()?);
let exp = this.read_scalar(args[1])?.to_i32()?;
// FIXME: We should use cmath if there are any imprecisions.
let n = x * 2.0f64.powi(exp);
extern {
fn ldexp(x: f64, n: i32) -> f64;
}
let n = unsafe { ldexp(x, exp) };
this.write_scalar(Scalar::from_u64(n.to_bits()), dest)?;
}