MCPcopy Create free account
hub / github.com/nodejs/node / assertAlmostEquals

Function assertAlmostEquals

deps/v8/test/mjsunit/math-exp-precision.js:38–47  ·  view source on GitHub ↗
(expected, actual, x)

Source from the content-addressed store, hash-verified

36var second_call_result = exp(Math.PI);
37
38function assertAlmostEquals(expected, actual, x) {
39 if (expected == 0 && actual == 0) return; // OK
40 if (expected == Number.POSITIVE_INFINITY &&
41 actual == Number.POSITIVE_INFINITY) {
42 return; // OK
43 }
44 relative_diff = Math.abs(expected/actual - 1);
45 assertTrue(relative_diff < 1e-12, "relative difference of " + relative_diff +
46 " for input " + x);
47}
48
49var increment = Math.PI / 35; // Roughly 0.1, but we want to try many
50 // different mantissae.

Callers 1

Calls 1

assertTrueFunction · 0.70

Tested by

no test coverage detected