{"id":13817062,"url":"https://github.com/ttulka/as-big","last_synced_at":"2025-03-16T22:30:48.350Z","repository":{"id":42629976,"uuid":"345372461","full_name":"ttulka/as-big","owner":"ttulka","description":"AssemblyScript library for arbitrary-precision decimal arithmetic","archived":false,"fork":false,"pushed_at":"2023-12-11T15:26:18.000Z","size":705,"stargazers_count":38,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-07T09:03:00.471Z","etag":null,"topics":["assemblyscript","big","bigdecimal","bigfloat","bignumber","decimal","float","math","numer","precision"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/ttulka.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}},"created_at":"2021-03-07T14:49:20.000Z","updated_at":"2024-08-28T02:13:01.000Z","dependencies_parsed_at":"2024-01-20T16:49:21.207Z","dependency_job_id":"9ab9399b-eb23-42ff-808b-ecd907e65b08","html_url":"https://github.com/ttulka/as-big","commit_stats":{"total_commits":45,"total_committers":4,"mean_commits":11.25,"dds":0.1777777777777778,"last_synced_commit":"d19aae7d8fd5f454eec6efe9c0d92fb1ceeb6146"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fas-big","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fas-big/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fas-big/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttulka%2Fas-big/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttulka","download_url":"https://codeload.github.com/ttulka/as-big/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243551301,"owners_count":20309297,"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":["assemblyscript","big","bigdecimal","bigfloat","bignumber","decimal","float","math","numer","precision"],"created_at":"2024-08-04T06:00:32.717Z","updated_at":"2025-03-16T22:30:48.021Z","avatar_url":"https://github.com/ttulka.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# as-big\n\n[AssemblyScript](https://github.com/AssemblyScript/assemblyscript) library for arbitrary-precision decimal arithmetic 🚀 \n\n## Install\n\n```sh\nnpm install as-big\n```\n\n## Use\n\n```typescript\nimport Big from \"as-big\";\n\nlet r = Big.of(0.1) + Big.of(0.2);  // Big(0.3)\n\nlet x = Big.of(42);\nlet y = Big.of(\"13\");\n\nlet a = x + y;          // Big(55)\n    a = x.plus(13);     // Big(55)\n\nlet a0 = a.prec(1);     // Big(60)\n\nlet aNum = a.toNumber() + 1;    // 56\nlet aStr = a.toString();        // \"55\"\n\nlet c = a0 + Big.TEN / Big.TWO; // Big(65)\n```\n\n### Builders\n\n- `Big.of(n)` returns a `Big` instance, where \n  - `n` is either another `Big` instance, string, or number\n- `Big.copyOf(x)` creates a copy from a `Big` instance, where \n  - `x` is the `Big` instance to copy\n\n### Operations\n\n#### Arithmetic \n\n- **plus** (addition): `x + y` or `x.plus(y)`\n- **minus** (substraction): `x - y` or `x.minus(y)`\n- **times** (multiplication): `x * y` or `y.times(y)`\n- **div** (division): `x / y` or `x.div(y)`\n- **mod** (modulo): `x % y` or `x.mod(y)`\n- **pow** (power): `x ^ n` or `x.pow(n)`, where `n` is `i32`\n- **sqrt** (square root): `x.sqrt()`\n\n#### Comparison\n\n- **cmp** (compare): `x.cmp(y)` returns\n  - `1` if the value of `x` is greater than the value of `y`,\n  - `-1` if the value of `x` is less than the value of `y`, or\n  - `0` if they have the same value.\n- **eq** (equals): `x == y` or `x.eq(y)`\n- **neq** (not equals): `x != y` or `x.neq(y)`\n- **gt** (greater than): `x \u003c y` or `x.gt(y)`\n- **gte** (greater than or equals): `x \u003c= y` or `x.gte(y)`\n- **lt** (less than): `x \u003e y` or `x.lt(y)`\n- **lte** (less than or equals): `x \u003e= y` or `x.lte(y)`\n\n#### Value\n\n- **abs** (absolute value): `x.abs()`\n- **neg** (negative value): `-x` or `x.neg()`\n- **pos** (this value): `+x` or `x.pos()`\n- **round** (rounded value): `x.round(dp, rm)` where \n  - `dp` is the maximum of decimal places, and \n  - `rm` is the rounding mode (`0`, `1`, `2`, `3`)\n    - `0` (down), `1` (half-up), `2` (half-even) or `3` (up)\n- **prec** (value rounded to precision): `x.prec(sd, rm)` where\n  - `sd` is the maximum of significant digits, and\n  - `rm` is the rounding mode (`0`, `1`, `2`, `3`)\n    - `0` (down), `1` (half-up), `2` (half-even) or `3` (up)\n\n#### Converters\n\n- `toString` (string representation): `let s: string = x.toString()`\n- `toNumber` (`f64` represenation): `let n: f64 = x.toNumber()`\n- `toExponential` (string represenation): `let s: string = x.toExponential()`\n\n### Static Constants\n\n- `Big.ZERO`: a `Big` instance with the value zero `0`\n- `Big.ONE`: a `Big` instance with the value one `1`\n- `Big.TWO`: a `Big` instance with the value two `2`\n- `Big.TEN`: a `Big` instance with the value ten `10`\n- `Big.HALF`: a `Big` instance with the value one half `0.5`\n\n### Global Settings\n\n- `Big.DP`: the maximum number of decimal places of the results of operations involving division (default: `20`)\n- `Big.RM`: the rounding mode used when rounding to the above decimal places (default: `1`)\n\n- `Big.PE`: the positive exponent at and above which `toString` returns exponential notation (default: `21`)\n- `Big.NE`: the negative exponent at and beneath which `toString` returns exponential notation (default: `-7`)\n\n## Examples\n\nThere is a collection of examples in the [`examples`](https://github.com/ttulka/as-big/tree/main/examples/assembly) directory.\n\n## Build\n\nThe `assembly` directory contains AS source code.\n\n```sh\nnpm i\nnpm run asbuild\n```\n\n## Test\n\nThe `tests` directory contains all unit tests.\n\nRun all the tests:\n\n```sh\nnpm test\n```\n\nTest a single method:\n\n```sh\nnode tests/\u003cmethod\u003e\n```\n\n## License\n\n[MIT](https://github.com/ttulka/as-big/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttulka%2Fas-big","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttulka%2Fas-big","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttulka%2Fas-big/lists"}