mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-23 03:31:44 +00:00
Even more math (#56)
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 `**`.
This commit is contained in:
@ -292,21 +292,6 @@ assert(f64.MIN_SAFE_INTEGER == -9007199254740991);
|
||||
assert(f64.MAX_SAFE_INTEGER == 9007199254740991);
|
||||
assert(f64.EPSILON == 2.2204460492503131e-16);
|
||||
|
||||
assert(isNaN<f64>(fmod(1, NaN)));
|
||||
assert(fmod(1.5, 1.0) == 0.5); // exactly 0.5 (as in C)
|
||||
assert(fmod(9.2, 2.0) - 1.2 < f64.EPSILON); // not exactly 1.2 (as in C)
|
||||
assert(fmod(9.2, 3.7) - 1.8 < f64.EPSILON); // not exactly 1.8 (as in C)
|
||||
|
||||
assert(isNaN<f32>(fmodf(1, NaN)));
|
||||
assert(fmodf(1.5, 1.0) == 0.5);
|
||||
assert(fmodf(9.2, 2.0) - 1.2 < f32.EPSILON);
|
||||
assert(fmodf(9.2, 3.7) - 1.8 < f32.EPSILON);
|
||||
|
||||
assert(1.5 % 1.0 == 0.5); // should implicitly call fmod
|
||||
assert(<f32>1.5 % 1.0 == 0.5); // should implicitly call fmodf
|
||||
|
||||
import {
|
||||
isNaN as isItNaN
|
||||
} from "builtins";
|
||||
|
||||
// should be importable
|
||||
import { isNaN as isItNaN } from "builtins";
|
||||
isItNaN(1);
|
||||
|
Reference in New Issue
Block a user