{"id":22059167,"url":"https://github.com/davidmartinez10/bigfloat-esnext","last_synced_at":"2025-05-12T19:43:46.787Z","repository":{"id":49605610,"uuid":"215511469","full_name":"davidmartinez10/bigfloat-esnext","owner":"davidmartinez10","description":"A library for arbitrary precision decimal floating point arithmetic.","archived":false,"fork":false,"pushed_at":"2022-12-16T17:58:33.000Z","size":129,"stargazers_count":4,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T14:19:51.799Z","etag":null,"topics":["arbitrary-precision","arithmetic","bigdecimal","bigfloat","bigfloat-esnext","bigint","bignumber","business","cryptocurrency","decimal","floating-point","math","mathematics","nodejs","physics","precision","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/bigfloat-esnext","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/davidmartinez10.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}},"created_at":"2019-10-16T09:39:58.000Z","updated_at":"2022-06-28T09:20:32.000Z","dependencies_parsed_at":"2023-01-29T15:31:16.822Z","dependency_job_id":null,"html_url":"https://github.com/davidmartinez10/bigfloat-esnext","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmartinez10%2Fbigfloat-esnext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmartinez10%2Fbigfloat-esnext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmartinez10%2Fbigfloat-esnext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmartinez10%2Fbigfloat-esnext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidmartinez10","download_url":"https://codeload.github.com/davidmartinez10/bigfloat-esnext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253639579,"owners_count":21940446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["arbitrary-precision","arithmetic","bigdecimal","bigfloat","bigfloat-esnext","bigint","bignumber","business","cryptocurrency","decimal","floating-point","math","mathematics","nodejs","physics","precision","typescript"],"created_at":"2024-11-30T17:27:22.314Z","updated_at":"2025-05-12T19:43:46.750Z","avatar_url":"https://github.com/davidmartinez10.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![BigFloat](https://raw.githubusercontent.com/davidmartinez10/bigfloat-esnext/master/bigfloat.jpg)](https://github.com/davidmartinez10/bigfloat-esnext)\n\nA library for arbitrary precision decimal floating point arithmetic that can exactly represent all decimal fractions,\nunlike JavaScript's number data type which is 64-bit binary floating point.\n\nBased on the original work by Douglas Crockford.\nThis implementation is built upon ES native bigints.\n\nThis library provides three ways to make bigfloat operations:\n  - A set of functions for a functional style approach\n  - A BigFloat class with an API similar to that of Decimal.js\n  - An evaluate() function that parses and resolves an expression\n\n# Basic usage\n### Functional style\n```typescript\nimport { make, string, sqrt } from \"bigfloat-esnext\";\n\nstring(sqrt(make(\"2\")));               // \"1.4142\"\n```\n\n### Class based\n```typescript\nimport { BigFloat } from \"bigfloat-esnext\";\n\nnew BigFloat(\"2\").sqrt().toString();   // \"1.4142\"\n```\n\n### The evaluate() function\n```typescript\nevaluate(expression: string, precision?: number): string | boolean\n```\n\u003eThe first argument can be any valid arithmetic or relational expression, including scientific e-notation.\n\u003ePrecision should be a negative integer. Default is -4.\n```typescript\nimport { evaluate } from \"bigfloat-esnext\";\n\n0.1 + 0.2 === 0.3;                     // false\nevaluate(\"0.1 + 0.2 == 0.3\");          // true\n\n0.1 + 0.2;                             // 0.30000000000000004\nevaluate(\"0.1 + 0.2\");                 // \"0.3\"\n\n1 + Number.EPSILON / 2;                // 1\nevaluate(`1 + ${Number.EPSILON / 2}`); // \"1.00000000000000011102230246251565\"\n\nevaluate(\"1 + 2.220446049250313e-16\"); // \"1.0000000000000002220446049250313\"\n\nevaluate(`4 \u003e= ${Math.PI}`);           // true\n```\n\nValid tokens:\n  - Parenthesis: (,)\n  - Number: Decimal, integer or scientific e-notation\n  - Operator: Arithmetic +,-,/,\\*,\\*\\* Relational =\\=\\=,=\\=,!==,!=,\u003c,\u003e,\u003c=,\u003e=\n### Change precision\n```typescript\nimport { BigFloat, set_precision } from \"bigfloat-esnext\";\n\nnew BigFloat(2).sqrt().toString();     // \"1.4142\"\nset_precision(-10);\nnew BigFloat(2).sqrt().toString();     // \"1.4142135623\"\n```\n### The bigfloat object\n```typescript\ninterface IBigFloat {\n  coefficient: bigint;\n  exponent: number;\n}\n```\nValid bigfloat made from primitives:\n```typescript\nconst bigfloat: IBigFloat {\n  coefficient: 522299n,\n  exponent: -4\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmartinez10%2Fbigfloat-esnext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidmartinez10%2Fbigfloat-esnext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmartinez10%2Fbigfloat-esnext/lists"}