{"id":21851837,"url":"https://github.com/nberlette/math","last_synced_at":"2026-01-24T04:12:05.660Z","repository":{"id":260388352,"uuid":"881159909","full_name":"nberlette/math","owner":"nberlette","description":"Standalone zero-dependency implementation of the entire `Math` namespace, compatible with any JS runtime.  ","archived":false,"fork":false,"pushed_at":"2026-01-12T17:07:59.000Z","size":179,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-12T21:37:17.856Z","etag":null,"topics":["arithmetic","constants","f16","floating-point","logarithmic","math","ponyfill","pure-javascript","rounding","trigonometry","type-guards","universal"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nberlette.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"ko_fi":"nberlette"}},"created_at":"2024-10-31T02:19:31.000Z","updated_at":"2026-01-12T17:08:04.000Z","dependencies_parsed_at":"2024-10-31T03:24:10.864Z","dependency_job_id":"bca8965b-164f-411e-bb9a-b0205ace0c5f","html_url":"https://github.com/nberlette/math","commit_stats":null,"previous_names":["nberlette/math"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/nberlette/math","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nberlette%2Fmath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nberlette%2Fmath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nberlette%2Fmath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nberlette%2Fmath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nberlette","download_url":"https://codeload.github.com/nberlette/math/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nberlette%2Fmath/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28711454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T23:51:44.727Z","status":"online","status_checked_at":"2026-01-24T02:00:06.909Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arithmetic","constants","f16","floating-point","logarithmic","math","ponyfill","pure-javascript","rounding","trigonometry","type-guards","universal"],"created_at":"2024-11-28T01:11:37.647Z","updated_at":"2026-01-24T04:12:05.655Z","avatar_url":"https://github.com/nberlette.png","language":"TypeScript","readme":"# `@nick/math`\n\n#### Dependency-free implementation of the `Math.*` namespace\n\n---\n\n## Overview\n\nThis package provides zero-dependency standalone implementations for all of the\n[functions] and [constants] found in the native [`Math`] namespace, _most_ of\nthose found on the global `Number` constructor function, with some additional\nnon-standard helpers, constants, and guards for various other purposes.\n\n## Usage\n\nWritten in pure TypeScript with absolutely zero dependencies. Organized in a\nmodular structure to facilitate bundler tree-shaking (dead code elimination),\nyou can either import the entire package as a namespace (useful for rapid\nprototyping during development), or on a modular basis where only the features\nrequired are imported (recommended for production).\n\nWhen imported as a namespace (or via the default export), this package is\nsuitable to use as a drop-in replacement for any standard `Math.*` feature's\nusage[^1].\n\n[^1]: All modules in this package are implemented using 100% manual logic and\n    arithmetic, and do not rely on any native code or objects. As such, the\n    performance will typically be slightly slower than the native `Math.*`\n    implementations. There may also be some minor deviations in output. If you\n    believe a specific function is inaccurate or otherwise inconsistent with the\n    expected behavior, please open an issue so I can address it and attempt to\n    improve it. Thank you!\n\n### Install\n\nThis package is published to [JSR] as `@nick/math`, and to [NPM] and [GPR] as\n`@nberlette/math`, for maximum availability on all major package managers:\n\n```sh\ndeno add jsr:@nick/math\n```\n\n```sh\npnpm add jsr:@nick/math\n```\n\n```sh\nyarn add jsr:@nick/math\n```\n\n```sh\nvlt add jsr:@nick/math\n```\n\n```sh\nbunx jsr add @nick/math\n```\n\n```sh\nnpx jsr add @nick/math\n```\n\n#### NPM and GPR\n\n```sh\ndeno add npm:@nberlette/math\n```\n\n```sh\npnpm add @nberlette/math\n```\n\n```sh\nyarn add @nberlette/math\n```\n\n```sh\nvlt add @nberlette/math\n```\n\n```sh\nbun add @nberlette/math\n```\n\n```sh\nnpm i @nberlette/math\n```\n\n### Example Usage\n\n#### Namespace\n\n```ts\nimport * as math from \"@nick/math\";\nimport assert from \"node:assert\";\n\nassert.ok((math.acos(0.5) - Math.acos(0.5)) \u003c 1e-9);\nassert.strictEqual(math.NEGATIVE_ZERO, -0);\nassert.strictEqual(math.PI, 3.141592653589793 /* Math.PI */);\n```\n\n#### Modular\n\n```ts\nimport { PI } from \"@nick/math/pi\";\nimport { f16round } from \"@nick/math/f16round\";\nimport { sign } from \"@nick/math/sign\";\nimport { NEGATIVE_INFINITY } from \"@nick/math/constants/negative-infinity\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(f16round(PI), 3.140625);\nassert.strictEqual(sign(-0), -0);\nassert.strictEqual(sign(PI), 1);\nassert.strictEqual(sign(NEGATIVE_INFINITY), -1);\n```\n\n---\n\n## API\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003e\u003cu\u003eTable of Contents\u003c/u\u003e\u003c/b\u003e\u003c/summary\u003e\u003cbr\u003e\n\n- [Constants](#constants)\n  - [`E` (Euler's number)](#e-eulers-number)\n  - [`LN10` (Natural logarithm of 10)](#ln10-natural-logarithm-of-10)\n  - [`LN2` (Natural logarithm of 2)](#ln2-natural-logarithm-of-2)\n  - [`LOG2E` (Base 2 logarithm of E)](#log2e-base-2-logarithm-of-e)\n  - [`LOG10E` (Base 10 logarithm of E)](#log10e-base-10-logarithm-of-e)\n  - [`PI` (π)](#pi-π)\n  - [`SQRT1_2` (Square root of 1/2)](#sqrt1_2-square-root-of-12)\n  - [`SQRT2` (Square root of 2)](#sqrt2-square-root-of-2)\n  - [`EPSILON`](#epsilon)\n  - [`MAX_SAFE_INTEGER`](#max_safe_integer)\n  - [`MIN_SAFE_INTEGER`](#min_safe_integer)\n  - [`MAX_VALUE`](#max_value)\n  - [`MIN_VALUE`](#min_value)\n  - [`NEGATIVE_INFINITY`](#negative_infinity)\n  - [`POSITIVE_INFINITY`](#positive_infinity)\n  - [`NAN`](#nan)\n- [Functions](#functions)\n  - [`abs`](#abs)\n  - [`acos`](#acos)\n  - [`acosh`](#acosh)\n  - [`asin`](#asin)\n  - [`asinh`](#asinh)\n  - [`atan`](#atan)\n  - [`atan2`](#atan2)\n  - [`atanh`](#atanh)\n  - [`cbrt`](#cbrt)\n  - [`ceil`](#ceil)\n  - [`clz32`](#clz32)\n  - [`cos`](#cos)\n  - [`cosh`](#cosh)\n  - [`exp`](#exp)\n  - [`expm1`](#expm1)\n  - [`floor`](#floor)\n  - [`fround`](#fround)\n  - [`f16round`](#f16round)\n  - [`hypot`](#hypot)\n  - [`imul`](#imul)\n  - [`log`](#log)\n  - [`log1p`](#log1p)\n  - [`log10`](#log10)\n  - [`log2`](#log2)\n  - [`max`](#max)\n  - [`min`](#min)\n  - [`pow`](#pow)\n  - [`random`](#random)\n  - [`round`](#round)\n  - [`sign`](#sign)\n  - [`sin`](#sin)\n  - [`sinh`](#sinh)\n  - [`sqrt`](#sqrt)\n  - [`tan`](#tan)\n  - [`tanh`](#tanh)\n  - [`trunc`](#trunc)\n- [Guards](#guards)\n  - [`isFinite`](#isfinite)\n  - [`isInteger`](#isinteger)\n  - [`isNaN`](#isnan)\n  - [`isSafeInteger`](#issafeinteger)\n  - [`isNegativeZero`](#isnegativezero)\n  - [`isPositiveInfinity`](#ispositiveinfinity)\n  - [`isNegativeInfinity`](#isnegativeinfinity)\n\n\u003c/details\u003e\n\n---\n\n### Constants\n\n#### `E` (Euler's number)\n\n```ts\nimport { E } from \"@nick/math/constants/e\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(E, 2.718281828459045);\n```\n\n#### `LN10` (Natural logarithm of 10)\n\n```ts\nimport { LN10 } from \"@nick/math/constants/ln10\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(LN10, 2.302585092994046);\n```\n\n#### `LN2` (Natural logarithm of 2)\n\n```ts\nimport { LN2 } from \"@nick/math/constants/ln2\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(LN2, 0.6931471805599453);\n```\n\n#### `LOG2E` (Base 2 logarithm of E)\n\n```ts\nimport { LOG2E } from \"@nick/math/constants/log2e\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(LOG2E, 1.4426950408889634);\n```\n\n#### `LOG10E` (Base 10 logarithm of E)\n\n```ts\nimport { LOG10E } from \"@nick/math/constants/log10e\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(LOG10E, 0.4342944819032518);\n```\n\n#### `PI` (π)\n\n```ts\nimport { PI } from \"@nick/math/constants/pi\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(PI, 3.141592653589793);\n```\n\n#### `SQRT1_2` (Square root of 1/2)\n\n```ts\nimport { SQRT1_2 } from \"@nick/math/constants/sqrt1_2\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(SQRT1_2, 0.7071067811865476);\n```\n\n#### `SQRT2` (Square root of 2)\n\n```ts\nimport { SQRT2 } from \"@nick/math/constants/sqrt2\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(SQRT2, 1.4142135623730951);\n```\n\n#### `EPSILON`\n\nRepresents the smallest positive number that can be added to `1` to get a result\ndifferent from `1`.\n\n```ts\nimport { EPSILON } from \"@nick/math/constants/epsilon\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(EPSILON, 2.220446049250313e-16);\n```\n\n#### `MAX_SAFE_INTEGER`\n\nThe maximum safe integer in JavaScript, `2^53 - 1`.\n\n```ts\nimport { MAX_SAFE_INTEGER } from \"@nick/math/constants/max-safe-integer\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(MAX_SAFE_INTEGER, 9007199254740991);\n```\n\n#### `MIN_SAFE_INTEGER`\n\nThe minimum safe integer in JavaScript, `-2^53 + 1`.\n\n```ts\nimport { MIN_SAFE_INTEGER } from \"@nick/math/constants/min-safe-integer\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(MIN_SAFE_INTEGER, -9007199254740991);\n```\n\n#### `MAX_VALUE`\n\nThe maximum representable value in JavaScript.\n\n```ts\nimport { MAX_VALUE } from \"@nick/math/constants/max-value\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(MAX_VALUE, 1.7976931348623157e308);\n```\n\n#### `MIN_VALUE`\n\nThe minimum representable value in JavaScript.\n\n```ts\nimport { MIN_VALUE } from \"@nick/math/constants/min-value\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(MIN_VALUE, 5e-324);\n```\n\n#### `NEGATIVE_INFINITY`\n\nThe negative infinity value in JavaScript.\n\n```ts\nimport { NEGATIVE_INFINITY } from \"@nick/math/constants/negative-infinity\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(NEGATIVE_INFINITY, -Infinity);\n```\n\n#### `POSITIVE_INFINITY`\n\nThe positive infinity value in JavaScript.\n\n```ts\nimport { POSITIVE_INFINITY } from \"@nick/math/constants/positive-infinity\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(POSITIVE_INFINITY, Infinity);\n```\n\n#### `NAN`\n\nThe `NaN` value in JavaScript, representing \"Not a Number\".\n\n```ts\nimport { NAN } from \"@nick/math/constants/nan\";\nimport assert from \"node:assert\";\n\nassert.ok(NAN !== NAN);\n```\n\n###### Alias: `NaN`\n\n```ts\nimport { NaN } from \"@nick/math/constants/nan\";\nimport assert from \"node:assert\";\n\nassert.ok(NaN !== NaN);\n```\n\n---\n\n### Functions\n\n#### `abs`\n\nReturns the absolute value of a number.\n\n```ts\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(abs(-1), 1);\n```\n\n#### `acos`\n\nReturns the arccosine of a number.\n\n```ts\nimport { acos } from \"@nick/math/acos\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(acos(0.5) - Math.acos(0.5)) \u003c 1e-9);\n```\n\n#### `acosh`\n\nReturns the inverse hyperbolic cosine of a number.\n\n```ts\nimport { acosh } from \"@nick/math/acosh\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(acosh(1), 0);\n```\n\n#### `asin`\n\nReturns the arcsine of a number.\n\n```ts\nimport { asin } from \"@nick/math/asin\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(asin(0.5) - Math.asin(0.5)) \u003c 1e-9);\n```\n\n#### `asinh`\n\nReturns the inverse hyperbolic sine of a number.\n\n```ts\nimport { asinh } from \"@nick/math/asinh\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(asinh(0.5) - Math.asinh(0.5)) \u003c 1e-9);\n```\n\n#### `atan`\n\nReturns the arctangent of a number.\n\n```ts\nimport { atan } from \"@nick/math/atan\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(atan(0.5) - Math.atan(0.5)) \u003c 1e-9);\n```\n\n#### `atan2`\n\nReturns the arctangent of the quotient of its arguments.\n\n```ts\nimport { atan2 } from \"@nick/math/atan2\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(atan2(1, 1), Math.atan2(1, 1));\n```\n\n#### `atanh`\n\nReturns the inverse hyperbolic tangent of a number.\n\n```ts\nimport { atanh } from \"@nick/math/atanh\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(atanh(0.5), Math.atanh(0.5));\n```\n\n#### `cbrt`\n\nReturns the cube root of a number.\n\n```ts\nimport { cbrt } from \"@nick/math/cbrt\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(cbrt(27), 3);\n```\n\n#### `ceil`\n\nReturns the smallest integer greater than or equal to a number.\n\n```ts\nimport { ceil } from \"@nick/math/ceil\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(ceil(1.5), 2);\n```\n\n#### `clz32`\n\nReturns the number of leading zero bits in the 32-bit binary representation of a\nnumber.\n\n```ts\nimport { clz32 } from \"@nick/math/clz32\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(clz32(1), 31);\n```\n\n#### `cos`\n\nReturns the cosine of a number.\n\n```ts\nimport { cos } from \"@nick/math/cos\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(cos(0.5) - Math.cos(0.5)) \u003c 1e-9);\n```\n\n#### `cosh`\n\nReturns the hyperbolic cosine of a number.\n\n```ts\nimport { cosh } from \"@nick/math/cosh\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(cosh(0.5) - Math.cosh(0.5)) \u003c 1e-9);\n```\n\n#### `exp`\n\nReturns `E` raised to the power of a number.\n\n```ts\nimport { exp } from \"@nick/math/exp\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(exp(1) - Math.exp(1)) \u003c 1e-9);\n```\n\n#### `expm1`\n\nReturns `E` raised to the power of a number, minus `1`.\n\n```ts\nimport { expm1 } from \"@nick/math/expm1\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(expm1(1) - Math.expm1(1)) \u003c 1e-9);\n```\n\n#### `floor`\n\nReturns the largest integer less than or equal to a number.\n\n```ts\nimport { floor } from \"@nick/math/floor\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(floor(1.5), 1);\n```\n\n#### `fround`\n\nReturns the nearest single precision float representation of a number.\n\n```ts\nimport { fround } from \"@nick/math/fround\";\nimport { PI } from \"@nick/math/constants/pi\";\n\nconsole.log(PI, \"-\u003e\", fround(PI));\n// 3.141592653589793 -\u003e 3.1415927410125732\n```\n\n#### `f16round`\n\nReturns the nearest 16-bit float representation of a number, as per the IEEE 754\nstandard. Introduced by the [TC39 Proposal for Float16Array].\n\n[TC39 Proposal for Float16Array]: https://github.com/tc39/proposal-Float16Array\n\n```ts\nimport { f16round } from \"@nick/math/f16round\";\nimport { PI } from \"@nick/math/constants/pi\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(f16round(PI), 3.140625);\n```\n\n#### `hypot`\n\nReturns the square root of the sum of the squares of its arguments.\n\n```ts\nimport { hypot } from \"@nick/math/hypot\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(hypot(3, 4), 5);\n```\n\n#### `imul`\n\nReturns the result of a 32-bit integer multiplication.\n\n```ts\nimport { imul } from \"@nick/math/imul\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(imul(2, 3), 6);\n```\n\n#### `log`\n\nReturns the natural logarithm of a number.\n\n```ts\nimport { log } from \"@nick/math/log\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(log(9) - Math.log(9)) \u003c 1e-9);\n```\n\n#### `log1p`\n\nReturns the natural logarithm of `1` plus a number.\n\n```ts\nimport { log1p } from \"@nick/math/log1p\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(log1p(9) - Math.log1p(9)) \u003c 1e-9);\n```\n\n#### `log10`\n\nReturns the base 10 logarithm of a number.\n\n```ts\nimport { log10 } from \"@nick/math/log10\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(log10(100) - Math.log10(100)) \u003c 1e-9);\n```\n\n#### `log2`\n\nReturns the base 2 logarithm of a number.\n\n```ts\nimport { log2 } from \"@nick/math/log2\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(log2(8) - Math.log2(8)) \u003c 1e-9);\n```\n\n#### `max`\n\nReturns the largest of zero or more numbers.\n\n```ts\nimport { max } from \"@nick/math/max\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(max(1, 2, 3), 3);\n```\n\n#### `min`\n\nReturns the smallest of zero or more numbers.\n\n```ts\nimport { min } from \"@nick/math/min\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(min(1, 2, 3), 1);\n```\n\n#### `pow`\n\nReturns the base to the exponent power.\n\n```ts\nimport { pow } from \"@nick/math/pow\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(pow(2, 3), 8);\n```\n\n#### `random`\n\nReturns a pseudo-random number between `0` and `1`.\n\n```ts\nimport { random } from \"@nick/math/random\";\nimport assert from \"node:assert\";\n\nconst value = random();\n\nassert.ok(value \u003e= 0 \u0026\u0026 value \u003c 1);\n```\n\n#### `round`\n\nReturns the value of a number rounded to the nearest integer.\n\n```ts\nimport { round } from \"@nick/math/round\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(round(1.5), 2);\n```\n\n#### `sign`\n\nReturns the sign of a number, indicating whether it is positive, negative, or\nzero.\n\n```ts\nimport { sign } from \"@nick/math/sign\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(sign(-1), -1);\n```\n\n#### `sin`\n\nReturns the sine of a number.\n\n```ts\nimport { sin } from \"@nick/math/sin\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(sin(0.5) - Math.sin(0.5)) \u003c 1e-9);\n```\n\n#### `sinh`\n\nReturns the hyperbolic sine of a number.\n\n```ts\nimport { sinh } from \"@nick/math/sinh\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(sinh(0.5) - Math.sinh(0.5)) \u003c 1e-9);\n```\n\n#### `sqrt`\n\nReturns the square root of a number.\n\n```ts\nimport { sqrt } from \"@nick/math/sqrt\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(sqrt(9), 3);\n```\n\n#### `tan`\n\nReturns the tangent of a number.\n\n```ts\nimport { tan } from \"@nick/math/tan\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(tan(0.5) - Math.tan(0.5)) \u003c 1e-9);\n```\n\n#### `tanh`\n\nReturns the hyperbolic tangent of a number.\n\n```ts\nimport { tanh } from \"@nick/math/tanh\";\nimport { abs } from \"@nick/math/abs\";\nimport assert from \"node:assert\";\n\nassert.ok(abs(tanh(0.5) - Math.tanh(0.5)) \u003c 1e-9);\n```\n\n#### `trunc`\n\nReturns the integer part of a number by removing any fractional digits.\n\n```ts\nimport { trunc } from \"@nick/math/trunc\";\nimport assert from \"node:assert\";\n\nassert.strictEqual(trunc(1.5), 1);\n```\n\n---\n\n### Guards\n\n#### `isFinite`\n\nDetermines whether a number is finite.\n\n```ts\nimport { isFinite } from \"@nick/math/is/finite\";\nimport assert from \"node:assert\";\n\nassert.ok(isFinite(1));\n```\n\n#### `isInteger`\n\nDetermines whether a number is an integer.\n\n```ts\nimport { isInteger } from \"@nick/math/is/integer\";\nimport assert from \"node:assert\";\n\nassert.ok(isInteger(1));\n```\n\n#### `isNaN`\n\nDetermines whether a value is `NaN`.\n\n```ts\nimport { isNaN } from \"@nick/math/is/nan\";\nimport assert from \"node:assert\";\n\nassert.ok(isNaN(NaN));\n```\n\n#### `isSafeInteger`\n\nDetermines whether a number is a safe integer.\n\n```ts\nimport { isSafeInteger } from \"@nick/math/is/safe-integer\";\nimport assert from \"node:assert\";\n\nassert.ok(isSafeInteger(1));\n```\n\n#### `isNegativeZero`\n\nDetermines whether a number is `-0`.\n\n```ts\nimport { isNegativeZero } from \"@nick/math/is/negative-zero\";\nimport assert from \"node:assert\";\n\nassert.ok(isNegativeZero(-0));\nassert.ok(!isNegativeZero(0));\n```\n\n#### `isPositiveInfinity`\n\nDetermines whether a number is positive infinity.\n\n```ts\nimport { isPositiveInfinity } from \"@nick/math/is/positive-infinity\";\nimport assert from \"node:assert\";\n\nassert.ok(isPositiveInfinity(Infinity));\n```\n\n#### `isNegativeInfinity`\n\nDetermines whether a number is negative infinity.\n\n```ts\nimport { isNegativeInfinity } from \"@nick/math/is/negative-infinity\";\nimport assert from \"node:assert\";\n\nassert.ok(isNegativeInfinity(-Infinity));\n```\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**[MIT] © [Nicholas Berlette]. All rights reserved.**\n\n\u003csmall\u003e\n\n[github] · [issues] · [jsr] · [npm] · [contributing]\n\n\u003c/small\u003e\u003c/div\u003e\n\n[MIT]: https://nick.mit-license.org \"MIT © Nicholas Berlette. All rights reserved.\"\n[Nicholas Berlette]: https://github.com/nberlette \"Follow nberlette on GitHub for more cool stuff!\"\n[GitHub]: https://github.com/nberlette/math \"Give nberlette/math a star on GitHub! ⭐️\"\n[Issues]: https://github.com/nberlette/math/issues \"Found a bug? Let's squash it! 🐛\"\n[JSR]: https://jsr.io/@nick/math \"View the @nick/math package on JSR\"\n[docs]: https://jsr.io/@nick/math/doc \"View auto-generated API documentation for @nick/math on JSR\"\n[NPM]: https://npmjs.com/package/@nberlette/math \"View @nberlette/math on NPM\"\n[contributing]: https://github.com/nberlette/math/blob/main/.github/CONTRIBUTING.md \"Contribution guidelines\"\n[`Math`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math\n","funding_links":["https://ko-fi.com/nberlette"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnberlette%2Fmath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnberlette%2Fmath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnberlette%2Fmath/lists"}