Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
🧮 Precise math utilities.
🧮 Precise math utilities.
Using this library, adding 0.2
+ 0.1
will result in 0.3
, and that might
look like nothing to the untrained eye, but it's not
what JavaScript usually does.
The way we achieve this is by using a tuple we called Precise
which contains a
representation of the base and exponent of a number using bigint
. We then do
all math operations over base and exponent in those tuples and turn them back to
number
when we are done.
Like all Coven Engineering libraries, it has 100% test coverage and it's built in top of modern tech compatible with all JavaScript runtimes.
Obviously, using this or any library like it is way more expensive than doing a simple math operation, so use this only when a precise value is required. If speed is more important than precision, avoid this or any library like it.
Example
import { calculate } from "@coven/math"; calculate(0.1).plus(0.2).total; // 0.3 🤯
Other links
Add Package
deno add jsr:@coven/math
Import symbol
import * as math from "@coven/math";
Import directly with a jsr specifier
import * as math from "jsr:@coven/math";
Add Package
pnpm i jsr:@coven/math
pnpm dlx jsr add @coven/math
Import symbol
import * as math from "@coven/math";
Add Package
yarn add jsr:@coven/math
yarn dlx jsr add @coven/math
Import symbol
import * as math from "@coven/math";
Add Package
vlt install jsr:@coven/math
Import symbol
import * as math from "@coven/math";
Add Package
npx jsr add @coven/math
Import symbol
import * as math from "@coven/math";
Add Package
bunx jsr add @coven/math
Import symbol
import * as math from "@coven/math";