Add acos, asin, and atan foreign functions
I copied the tests from the docs pages
This commit is contained in:
parent
35e92d9420
commit
a328683c4a
@ -496,7 +496,7 @@ fn emulate_foreign_item(
|
||||
}
|
||||
|
||||
// math functions
|
||||
"cbrtf" | "coshf" | "sinhf" | "tanf" => {
|
||||
"cbrtf" | "coshf" | "sinhf" | "tanf" | "acosf" | "asinf" | "atanf" => {
|
||||
// FIXME: Using host floats.
|
||||
let f = f32::from_bits(this.read_scalar(args[0])?.to_u32()?);
|
||||
let f = match link_name {
|
||||
@ -504,6 +504,9 @@ fn emulate_foreign_item(
|
||||
"coshf" => f.cosh(),
|
||||
"sinhf" => f.sinh(),
|
||||
"tanf" => f.tan(),
|
||||
"acosf" => f.acos(),
|
||||
"asinf" => f.asin(),
|
||||
"atanf" => f.atan(),
|
||||
_ => bug!(),
|
||||
};
|
||||
this.write_scalar(Scalar::from_u32(f.to_bits()), dest)?;
|
||||
@ -521,7 +524,7 @@ fn emulate_foreign_item(
|
||||
this.write_scalar(Scalar::from_u32(n.to_bits()), dest)?;
|
||||
}
|
||||
|
||||
"cbrt" | "cosh" | "sinh" | "tan" => {
|
||||
"cbrt" | "cosh" | "sinh" | "tan" | "acos" | "asin" | "atan" => {
|
||||
// FIXME: Using host floats.
|
||||
let f = f64::from_bits(this.read_scalar(args[0])?.to_u64()?);
|
||||
let f = match link_name {
|
||||
@ -529,6 +532,9 @@ fn emulate_foreign_item(
|
||||
"cosh" => f.cosh(),
|
||||
"sinh" => f.sinh(),
|
||||
"tan" => f.tan(),
|
||||
"acos" => f.acos(),
|
||||
"asin" => f.asin(),
|
||||
"atan" => f.atan(),
|
||||
_ => bug!(),
|
||||
};
|
||||
this.write_scalar(Scalar::from_u64(f.to_bits()), dest)?;
|
||||
|
@ -92,6 +92,15 @@ pub fn main() {
|
||||
assert_approx_eq!(1.0f32.tan(), 1.557408f32);
|
||||
assert_approx_eq!(1.0f64.tan(), 1.557408f64);
|
||||
|
||||
assert_approx_eq!(f32::consts::FRAC_PI_4.cos().acos(), f32::consts::FRAC_PI_4);
|
||||
assert_approx_eq!(f64::consts::FRAC_PI_4.cos().acos(), f64::consts::FRAC_PI_4);
|
||||
|
||||
assert_approx_eq!(f32::consts::FRAC_PI_4.sin().asin(), f32::consts::FRAC_PI_4);
|
||||
assert_approx_eq!(f64::consts::FRAC_PI_4.sin().asin(), f64::consts::FRAC_PI_4);
|
||||
|
||||
assert_approx_eq!(1.0_f32, 1.0_f32.tan().atan());
|
||||
assert_approx_eq!(1.0_f64, 1.0_f64.tan().atan());
|
||||
|
||||
assert_eq!(3.3_f32.round(), 3.0);
|
||||
assert_eq!(3.3_f64.round(), 3.0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user