Module

x/justaos_orm/test/test.deps.ts>assertAlmostEquals

JUSTAOS's ORM (Object–relational mapping) tool is built for Deno and provides transparent persistence for JavaScript objects to Postgres database.
Go to Latest
function assertAlmostEquals
import { assertAlmostEquals } from "https://dotland.deno.dev/x/justaos_orm@v6.4.0/test/test.deps.ts";

Make an assertion that actual and expected 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.

Examples

Example 1

import { assertAlmostEquals } from "https://deno.land/std@$STD_VERSION/assert/mod.ts";

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

Parameters

actual: number
expected: number
optional
tolerance = [UNSUPPORTED]
optional
msg: string