This commit is contained in:
Ralf Jung
2019-08-10 11:33:33 +02:00
parent 33eb5657d6
commit 04892d9155
+3 -1
View File
@@ -597,8 +597,9 @@ fn emulate_foreign_item(
"_ldexp" | "ldexp" | "scalbn" => {
let x = this.read_scalar(args[0])?.to_f64()?;
let exp = this.read_scalar(args[1])?.to_i32()?;
// Saturating cast to i16. Even those are outside the valid exponent range to
// `scalbn` below will to its over/underflow handling.
// `scalbn` below will do its over/underflow handling.
let exp = if exp > i16::max_value() as i32 {
i16::max_value()
} else if exp < i16::min_value() as i32 {
@@ -606,6 +607,7 @@ fn emulate_foreign_item(
} else {
exp.try_into().unwrap()
};
let res = x.scalbn(exp);
this.write_scalar(Scalar::from_f64(res), dest)?;
}