{"id":15059404,"url":"https://github.com/dwayne/elm-integer","last_synced_at":"2025-04-10T05:30:21.039Z","repository":{"id":210513600,"uuid":"719291601","full_name":"dwayne/elm-integer","owner":"dwayne","description":"The integers, ℤ = { ..., -2, -1, 0, 1, 2, ... }.","archived":false,"fork":false,"pushed_at":"2024-03-12T20:56:32.000Z","size":114,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T06:51:30.927Z","etag":null,"topics":["arbitrary-precision","bignum","elm","extended-precision","integers","multiple-precision"],"latest_commit_sha":null,"homepage":"https://package.elm-lang.org/packages/dwayne/elm-integer/latest/","language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dwayne.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2023-11-15T21:25:19.000Z","updated_at":"2023-12-26T19:55:49.000Z","dependencies_parsed_at":"2025-02-16T16:44:27.576Z","dependency_job_id":null,"html_url":"https://github.com/dwayne/elm-integer","commit_stats":null,"previous_names":["dwayne/elm-integer"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwayne%2Felm-integer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwayne%2Felm-integer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwayne%2Felm-integer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwayne%2Felm-integer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwayne","download_url":"https://codeload.github.com/dwayne/elm-integer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248162870,"owners_count":21057826,"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","bignum","elm","extended-precision","integers","multiple-precision"],"created_at":"2024-09-24T22:43:10.233Z","updated_at":"2025-04-10T05:30:20.965Z","avatar_url":"https://github.com/dwayne.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elm Integer\n\nA pure Elm library for computing with the [integers](https://en.wikipedia.org/wiki/Integer),\nℤ = { ..., -2, -1, 0, 1, 2, ... }.\n\n## What's available?\n\n### The integers from -10 to 10\n\n- `negativeTen`\n- `negativeNine`\n- `negativeEight`\n- `negativeSeven`\n- `negativeSix`\n- `negativeFive`\n- `negativeFour`\n- `negativeThree`\n- `negativeTwo`\n- `negativeOne`\n- `zero`\n- `one`\n- `two`\n- `three`\n- `four`\n- `five`\n- `six`\n- `seven`\n- `eight`\n- `nine`\n- `ten`\n\n### Ways to create integers from an `Int` or a [`Natural`][Natural]\n\n- `fromSafeInt`\n- `fromInt`\n- `fromNatural`\n\n### Ways to create integers from a `String`\n\n- `fromSafeString`\n- `fromString`\n- `fromBinaryString`\n- `fromOctalString`\n- `fromDecimalString`\n- `fromHexString`\n- `fromBaseBString`\n\n### Comparison operators\n\n- `==`\n- `/=`\n- `compare`\n- `isLessThan`\n- `isLessThanOrEqual`\n- `isGreaterThan`\n- `isGreaterThanOrEqual`\n- `max`\n- `min`\n\n### Predicates for classification\n\n- `isNegative` (i.e. `\u003c 0`)\n- `isNonNegative` (i.e. `\u003e= 0`)\n- `isZero` (i.e. `== 0`)\n- `isNonZero` (i.e. `/= 0`)\n- `isPositive` (i.e. `\u003e 0`)\n- `isNonPositive` (i.e. `\u003c= 0`)\n- `isEven`\n- `isOdd`\n\n### Arithmetic\n\n- `abs`\n- `negate`\n- `add`\n- `sub`\n- `mul`\n- `divModBy` (Euclidean division)\n- `divBy`\n- `modBy`\n- `quotRemBy` (differs from `divModBy` in its handling of negative operands)\n- `quotBy`\n- `remBy`\n- `exp`\n\n### Ways to convert to an `Int` or a [`Natural`][Natural]\n\n- `toInt`\n- `toNatural`\n\n**N.B.** *Please remember to use them with caution since they discard information.*\n\n### Ways to convert to a `String`\n\n- `toString` (same as `toDecimalString`)\n- `toBinaryString`\n- `toOctalString`\n- `toDecimalString`\n- `toHexString`\n- `toBaseBString`\n\n## Examples\n\n### Calculator - [Live Demo](https://dwayne.github.io/elm-integer/)\n\nIn the `examples/calculator` directory you will find the implementation of a simple integer calculator web application. The calculator\nis designed and built to make it easy to test out all the **integer input formats**, **arithmetic operations**, and\n**integer output formats** that's supported by this library.\n\nYou are able to enter your expression using an [S-expression](https://en.wikipedia.org/wiki/S-expression) based language. The\nfollowing syntax is supported:\n\n```txt\nExpr      ::= Integer\n            | '(' 'abs' Expr ')'\n            | '(' 'negate' Expr ')'\n            | '(' 'add' Expr* ')'\n            | '(' 'sub' Expr Expr ')'\n            | '(' 'mul' Expr* ')'\n            | '(' 'div' Expr Expr ')'\n            | '(' 'mod' Expr Expr ')'\n            | '(' 'quot' Expr Expr ')'\n            | '(' 'rem' Expr Expr ')'\n            | '(' 'exp' Expr Expr ')'\nInteger   ::= Sign Magnitude\nSign      ::= '-'?\nMagnitude ::= ('0b' | '0B') Binary\n            | ('0o' | '0O') Octal\n            | ('0x' | '0X') Hex\n            | Decimal\nBinary    ::= [0-1]+\nOctal     ::= [0-7]+\nHex       ::= [0-9a-fA-F]+\nDecimal   ::= [0-9]+\n```\n\n**N.B.** *You must be in the Nix development shell (`nix develop`) to run the scripts mentioned below.*\n\n#### Build\n\nBuild the calculator web application.\n\n```sh\n$ build-examples-calculator\n```\n\n#### Run\n\nServe the calculator web application.\n\n```sh\n$ serve-examples-calculator\n```\n\nThen, open `http://localhost:8000` in your browser to run the calculator.\n\n## Performance\n\n**TL;DR** The performance of this library depends solely on the performance of [`elm-natural`][elm-natural].\n\nThis library is built on `elm-natural` and each function that is implemented using functions from `elm-natural` only introduces\na constant amount of overhead. As a result, the performance characteristics of a given function, `f`, from this library are\ndirectly related to\n[the performance characteristics of the functions from elm-natural][elm-natural-performance]\nthat are used to implement `f`. Practically speaking, this means that any performance gains in `elm-natural` will necessarily\nlead to corresponding performance gains within `elm-integer`.\n\n## Resources\n\n- Chapter 18 - Arbitrary-Precision Arithmetic of [C Interfaces and Implementations: Techniques for Creating Reusable Software](https://archive.org/details/cinterfacesimple0000hans) helped me to design, organize and implement the library.\n- [Euclidean Division: Integer Division with Remainders](https://www.probabilisticworld.com/euclidean-division-integer-division-with-remainders/) by Probabilistic World helped me to understand all the competing definitions of integer division with remainders.\n\n[elm-natural]: https://package.elm-lang.org/packages/dwayne/elm-natural/1.1.1\n[Natural]: https://package.elm-lang.org/packages/dwayne/elm-natural/1.1.1/Natural\n[elm-natural-performance]: https://github.com/dwayne/elm-natural/tree/1.1.1#performance\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwayne%2Felm-integer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwayne%2Felm-integer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwayne%2Felm-integer/lists"}