{"id":22059170,"url":"https://github.com/davidmartinez10/bigfloat","last_synced_at":"2025-05-12T19:43:36.669Z","repository":{"id":34071254,"uuid":"168459097","full_name":"davidmartinez10/bigfloat","owner":"davidmartinez10","description":"A library for arbitrary precision decimal floating point arithmetic.","archived":false,"fork":false,"pushed_at":"2022-03-24T20:19:34.000Z","size":150,"stargazers_count":18,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-16T16:13:50.275Z","etag":null,"topics":["arbitrary-precision","arithmetic","bigdecimal","bigfloat","bigint","bignumber","business","cryptocurrency","decimal","floating-point","math","mathematics","nodejs","physics","precision","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/bigfloat.js","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-01-31T03:50:27.000Z","updated_at":"2025-01-05T17:19:27.000Z","dependencies_parsed_at":"2022-08-08T00:00:33.554Z","dependency_job_id":null,"html_url":"https://github.com/davidmartinez10/bigfloat","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmartinez10%2Fbigfloat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmartinez10%2Fbigfloat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmartinez10%2Fbigfloat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmartinez10%2Fbigfloat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidmartinez10","download_url":"https://codeload.github.com/davidmartinez10/bigfloat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253809684,"owners_count":21967774,"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","bigint","bignumber","business","cryptocurrency","decimal","floating-point","math","mathematics","nodejs","physics","precision","typescript"],"created_at":"2024-11-30T17:27:23.750Z","updated_at":"2025-05-12T19:43:36.643Z","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)\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 the Google Chrome Labs' implementation of ECMAScript big integers: JSBI.\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\nNOTE: This is a compatibility package intended for cross-browser support. If you are targetting Node.js, Electron or any engine that supports native bigints and the exponentiation operator(**), then you don't need JSBI and you should be using [bigfloat-esnext](https://github.com/davidmartinez10/bigfloat-esnext).\n\n# Basic usage\n### Functional style\n```typescript\nimport { make, string, sqrt } from \"bigfloat.js\";\n\nstring(sqrt(make(\"2\")));               // \"1.4142\"\n```\n\n### Class based\n```typescript\nimport { BigFloat } from \"bigfloat.js\";\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\u003e(Optional) Precision should be a negative integer. Default is -4.\n```typescript\nimport { evaluate } from \"bigfloat.js\";\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.js\";\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: JSBI;\n  exponent: number;\n}\n```\nValid bigfloat made from primitives:\n```typescript\nconst bigfloat: IBigFloat {\n  coefficient: JSBI.BigInt(522299),\n  exponent: -4\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmartinez10%2Fbigfloat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidmartinez10%2Fbigfloat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmartinez10%2Fbigfloat/lists"}