{"id":19937107,"url":"https://github.com/oldj/big-int.js","last_synced_at":"2025-05-03T14:31:06.115Z","repository":{"id":5040980,"uuid":"6201182","full_name":"oldj/big-int.js","owner":"oldj","description":"Big Integer for JavaScript.","archived":false,"fork":false,"pushed_at":"2017-05-14T14:49:44.000Z","size":1894,"stargazers_count":30,"open_issues_count":0,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-15T13:51:20.086Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://oldj.net/static/js-BIO/eg.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"niutech/typescript-compile","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oldj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-13T08:23:05.000Z","updated_at":"2023-01-30T02:28:59.000Z","dependencies_parsed_at":"2022-09-15T06:22:18.882Z","dependency_job_id":null,"html_url":"https://github.com/oldj/big-int.js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldj%2Fbig-int.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldj%2Fbig-int.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldj%2Fbig-int.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldj%2Fbig-int.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oldj","download_url":"https://codeload.github.com/oldj/big-int.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252203185,"owners_count":21710903,"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":[],"created_at":"2024-11-12T23:30:56.872Z","updated_at":"2025-05-03T14:31:04.866Z","avatar_url":"https://github.com/oldj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JavaScript Big-Int\n\n - Author: oldj\n - Blog: http://oldj.net\n - Example: http://oldj.net/static/js-BIO/eg.html\n\nThis library is made for big integer operations in JavaScript, such as *add*, *subtract*, *multiply*, *divide*, *mod*, compare, etc.\n\nThe principle of this library is to simulate pen and paper operation, you can operate integers as big as your RAM allowed.\n\n## Install\n\n```\nnpm install --save big-int\n```\n\n## Example\n\n```js\nvar bigInt = require('big-int');\n\nvar a = '218093290301725279849294552737145306526429515095910348328784867259719961681262317171990366018836471452273795738712382654617011499370332067465452153429131133154474494728461513797156576311424209209825768452476998761186844896333150192092696406370188813135474544186922431865203259468892782696696554856807492686240273426580684476908600903286664578178500293562463803241679236095343405558144595606432072340054';\nvar b = '759453421168594746297585634824794585057708073795685055048450994660667302169842440997187780071628842999365618342370044730249364762070171939525787172608446535167458760784909718498489041640160903072085566658168644606091524276643802085431070120034640336353069020700940598038997582524596177336508';\nvar c;\n\n// a + b\nc = bigInt(a).add(b);\nconsole.log(c.val()); // =\u003e 218093290301725279849294552737145306526429515095910348328784867259719961681262317171990366018836471452273795739471836075785606245667917702290246738486839206950159549776912508457823878481266650207013548524105841760552463238703194922342061168440360752661261716795368967032662020253802501195185596496968395758325840084749329083000125179930466663609570413597104139594748256796284003597142178131028249676562\n\n// a - b\nc = bigInt(a).sub(b);\nconsole.log(c.val()); // =\u003e 218093290301725279849294552737145306526429515095910348328784867259719961681262317171990366018836471452273795737952929233448416753072746432640657568371423059358789439680010519136489274141581768212637988380848155761821226553963105461843331644300016873609687371578475896697744498683983064198207513216646589614154706768412039870817076626642862492747430173527823466888610215394402807519147013081835895003546\n\n// a * b\nc = bigInt(a).mul(b);\nconsole.log(c.val()); // =\u003e 165631695453560768931354179676327783789554654471289094267396314999551619350086706770637603163259782521350605065527228675367441009889563464536042123812298158775025038552756989906635218183772046533558978457853765293877902141330057087553963131601282691171759816841117292436049592274238065569156249246125691526163874951713797884657704497629753668671292281869762553374641310311774140912980126830919151808832669504364383900117665833031771105917192115442091637918088985032215601898962325376736104912045524501146768304386244267559527475259139329594399610587041338732488477674534017135328109239900803529659849632039837754817318175918697532072796924765669004218196032450409366708571087537016172564891432\n\n// a / b\nc = bigInt(a).div(b);\nconsole.log(c.val()); // =\u003e 287171384343938182302166283267955634005236318876904228926536131374862297188572994580923635532994904266143630527\n\n// a mod b\nc = bigInt(a).mod(b);\nconsole.log(c.val()); // =\u003e 592025574073873421838644719778706564169852072684877302818315404363803007260660346662730591457239291807144570448333654917475379749402034885167586678975138436729309695698180319906813373242540831615098968972192135361399928745893872371373756948364150937205578085919887319866770529450275971960338\n\n// chain usage\nc = bigInt('100')\n    .add('50') // 150\n    .sub('10') // 140\n    .mul('2') // 280\n    .div('11'); // 25\nconsole.log(c.val()); // 25\n```\n\n## APIs\n\n### .add(n)\n\nadd n.\n\n### .sub(n)\n\nsub n.\n\n### .mul(n)\n\nmultiply by n.\n\n### .div(n)\n\ndivide by n.\n\n### .mod(n)\n\nget the modulo by n.\n\n### .abs()\n\nreturn the absolute value.\n\n### .neg()\n\nreturn a new bigint with the negative of the instance value.\n\n### cmp(n)\n\ncompare with `n`, return `1` if the instance value is greater than `n`, `0` if they are equal, `-1` if the instance value is less than `n`.\n\n### lt(n)\n\nif the instance value is less than `n`.\n\n### lte(n)\n\nif the instance value is less than or equal `n`.\n\n### gt(n)\n\nif the instance value is greater than `n`.\n\n### gte(n)\n\nif the instance value is greater than or equal `n`.\n\n## Log\n\n - 2016-07-20 Some change, and then publish to [npm](https://www.npmjs.com/package/big-int).\n - 2012-10-13 The first version.\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foldj%2Fbig-int.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foldj%2Fbig-int.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foldj%2Fbig-int.js/lists"}