Optional
tolerance: numberOptional
msg: string24.7.0
import { assertAlmostEquals } from "assert";
assertAlmostEquals(0.01, 0.02, 0.1); // Doesn't throw
assertAlmostEquals(0.01, 0.02); // Throws
assertAlmostEquals(0.1 + 0.2, 0.3, 1e-16); // Doesn't throw
assertAlmostEquals(0.1 + 0.2, 0.3, 1e-17); // Throws
Make an assertion that
actual
andexpected
are almost equal numbers through a given tolerance. It can be used to take into account IEEE-754 double-precision floating-point representation limitations. If the values are not almost equal then throw.