No description
Find a file
2024-02-15 21:33:14 +02:00
src Fix power function to return a result 2024-02-15 21:33:14 +02:00
test Fix power function to return a result 2024-02-15 21:33:14 +02:00
.gitignore Initial commit 2024-02-04 00:38:53 +02:00
.tool-versions Initial commit 2024-02-04 00:38:53 +02:00
CHANGELOG.txt Fix power function to return a result 2024-02-15 21:33:14 +02:00
gleam.toml Add Hex publish information 2024-02-04 16:40:46 +02:00
LICENSE Initial commit 2024-02-04 00:38:53 +02:00
manifest.toml Initial commit 2024-02-04 00:38:53 +02:00
README.md Fix power function to return a result 2024-02-15 21:33:14 +02:00

bigi

Package Version Hex Docs

Arbitrary precision integer arithmetic for Gleam.

In the Erlang target, all integers are automatically "big integers" that are subject to arbitrary precision arithmetic. This means there is no need for this package if you are only targeting Erlang.

In JavaScript, Gleam's Int type corresponds to the number type, which is implemented using floating-point arithmetic. That means it's subject to the following limits:

This package thus provides big integers for the JavaScript target and additionally provides a consistent interface for packages that target both Erlang and JavaScript. In Erlang, regular integers are used. In JavaScript, the BigInt type is used.

gleam add bigi
import bigi

pub fn main() {
  bigi.power(
    bigi.from_int(2),
    bigi.from_int(65_535)
  )

  // Ok(1001764965203423232489536175780127875223912737784875709632508486855447029778...)
}

Further documentation can be found at https://hexdocs.pm/bigi.

Development

gleam run   # Run the project
gleam test  # Run the tests
gleam shell # Run an Erlang shell