Closed itchyny closed 2 years ago
Maybe we can use macro here?
macro_rules! pub_math_fn {
($($name: ident),*) => {
$(
pub(crate) fn $name(v: Number) -> Result<Number> {
Ok(v.$name())
}
)*
};
}
pub_math_fn!(floor, sqrt, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh);
Niiice, thank you!
This PR adds trigonometric functions, inverse trigonometric functions, hyperbolic functions, and inverse hyperbolic functions. In tests, I used
floor
to round the results because we cannot get some floating-point number exactly (for example, we can't test2 | sin
equals to0.9092974268256817
due to deserializing error). Also note that current testing macro does not allow to test nan value (and maybe infinite as well).