mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
Remaining implementations of JavaScript's Math functions (except sin/cos/tan), both double (Math) and single (Mathf) precision, ported from musl incl. tests from libc-test, plus some changes to match JS semantics. Also binds fmod to `%` and pow to `**`.
145 lines
2.4 KiB
TypeScript
145 lines
2.4 KiB
TypeScript
export const E = Math.E;
|
|
export const LN10 = Math.LN10;
|
|
export const LN2 = Math.LN2;
|
|
export const LOG10E = Math.LOG10E;
|
|
export const LOG2E = Math.LOG2E;
|
|
export const PI = Math.PI;
|
|
export const SQRT1_2 = Math.SQRT1_2;
|
|
export const SQRT2 = Math.SQRT2;
|
|
|
|
export function abs(x: f64): f64 {
|
|
return Math.abs(x);
|
|
}
|
|
|
|
export function acos(x: f64): f64 {
|
|
return Math.acos(x);
|
|
}
|
|
|
|
export function acosh(x: f64): f64 {
|
|
return Math.acosh(x);
|
|
}
|
|
|
|
export function asin(x: f64): f64 {
|
|
return Math.asin(x);
|
|
}
|
|
|
|
export function asinh(x: f64): f64 {
|
|
return Math.asinh(x);
|
|
}
|
|
|
|
export function atan(x: f64): f64 {
|
|
return Math.atan(x);
|
|
}
|
|
|
|
export function atanh(x: f64): f64 {
|
|
return Math.atanh(x);
|
|
}
|
|
|
|
export function atan2(y: f64, x: f64): f64 {
|
|
return Math.atan2(y, x);
|
|
}
|
|
|
|
export function cbrt(x: f64): f64 {
|
|
return Math.cbrt(x);
|
|
}
|
|
|
|
export function ceil(x: f64): f64 {
|
|
return Math.ceil(x);
|
|
}
|
|
|
|
export function clz32(x: f64): f64 {
|
|
return Math.clz32(x);
|
|
}
|
|
|
|
export function cos(x: f64): f64 {
|
|
return Math.cos(x);
|
|
}
|
|
|
|
export function cosh(x: f64): f64 {
|
|
return Math.cosh(x);
|
|
}
|
|
|
|
export function exp(x: f64): f64 {
|
|
return Math.exp(x);
|
|
}
|
|
|
|
export function expm1(x: f64): f64 {
|
|
return Math.expm1(x);
|
|
}
|
|
|
|
export function floor(x: f64): f64 {
|
|
return Math.floor(x);
|
|
}
|
|
|
|
export function fround(x: f64): f32 {
|
|
return Math.fround(x);
|
|
}
|
|
|
|
export function hypot(a: f64, b: f64): f64 {
|
|
return Math.hypot(a, b);
|
|
}
|
|
|
|
export function imul(a: f64, b: f64): f64 {
|
|
return Math.imul(a, b);
|
|
}
|
|
|
|
export function log(x: f64): f64 {
|
|
return Math.log(x);
|
|
}
|
|
|
|
export function log10(x: f64): f64 {
|
|
return Math.log10(x);
|
|
}
|
|
|
|
export function log1p(x: f64): f64 {
|
|
return Math.log1p(x);
|
|
}
|
|
|
|
export function log2(x: f64): f64 {
|
|
return Math.log2(x);
|
|
}
|
|
|
|
export function max(a: f64, b: f64): f64 {
|
|
return Math.max(a, b);
|
|
}
|
|
|
|
export function min(a: f64, b: f64): f64 {
|
|
return Math.min(a, b);
|
|
}
|
|
|
|
export function pow(x: f64, y: f64): f64 {
|
|
return Math.pow(x, y);
|
|
}
|
|
|
|
export function round(x: f64): f64 {
|
|
return Math.round(x);
|
|
}
|
|
|
|
export function sign(x: f64): f64 {
|
|
return Math.sign(x);
|
|
}
|
|
|
|
export function sin(x: f64): f64 {
|
|
return Math.sin(x);
|
|
}
|
|
|
|
export function sinh(x: f64): f64 {
|
|
return Math.sinh(x);
|
|
}
|
|
|
|
export function sqrt(x: f64): f64 {
|
|
return Math.sqrt(x);
|
|
}
|
|
|
|
export function tan(x: f64): f64 {
|
|
return Math.tan(x);
|
|
}
|
|
|
|
export function tanh(x: f64): f64 {
|
|
return Math.tanh(x);
|
|
}
|
|
|
|
export function trunc(x: f64): f64 {
|
|
return Math.trunc(x);
|
|
}
|