]> git.lizzy.rs Git - rust.git/commitdiff
Use ldexp from cmath instead
authorChristian Poveda <christianpoveda@protonmail.com>
Thu, 8 Aug 2019 20:22:34 +0000 (15:22 -0500)
committerChristian Poveda <christianpoveda@protonmail.com>
Thu, 8 Aug 2019 20:45:58 +0000 (15:45 -0500)
src/shims/foreign_items.rs

index 37e5fe42c3de7829f71c77d48f87700ba12d3972..ba9b7ca27eb0514795cfd179bb8159fcd41e995b 100644 (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)?;
             }