# Types

## BigInt

</>

A big integer.

``pub type BigInt``

# Functions

## absolute

</>
``pub fn absolute(bigint: BigInt) -> BigInt``

Get the absolute value of a big integer.

</>
``pub fn add(a: BigInt, b: BigInt) -> BigInt``

Add two big integers together.

## compare

</>
``pub fn compare(a: BigInt, with b: BigInt) -> Order``

Compare two big integers, returning an order that denotes if `b` is lower, bigger than, or equal to `a`.

## digits

</>
``pub fn digits(bigint: BigInt) -> List(Int)``

Get the digits in a given bigint as a list of integers.

The list is ordered starting from the most significant digit.

## divide

</>
``pub fn divide(dividend a: BigInt, divisor b: BigInt) -> BigInt``

Divide the dividend with the divisor using integer division.

Follows the standard Gleam divide-by-zero rule of 0 when the divisor is 0.

## divide_no_zero

</>
``````pub fn divide_no_zero(
dividend a: BigInt,
divisor b: BigInt,
) -> Result(BigInt, Nil)``````

Divide the dividend with the divisor using integer division.

Returns an error if the divisor is 0.

## from_int

</>
``pub fn from_int(int: Int) -> BigInt``

Create a big integer from a regular integer.

## modulo

</>
``pub fn modulo(dividend a: BigInt, divisor b: BigInt) -> BigInt``

Calculate a mathematical modulo operation.

Follows the standard Gleam divide-by-zero rule of 0 when the divisor is 0.

## modulo_no_zero

</>
``````pub fn modulo_no_zero(
dividend a: BigInt,
divisor b: BigInt,
) -> Result(BigInt, Nil)``````

Calculate a mathematical modulo operation.

Returns an error if the divisor is 0.

## multiply

</>
``pub fn multiply(a: BigInt, b: BigInt) -> BigInt``

Multiply two big integers together.

## power

</>
``pub fn power(base a: BigInt, exponent b: BigInt) -> BigInt``

Raise the base to the exponent.

## remainder

</>
``pub fn remainder(dividend a: BigInt, divisor b: BigInt) -> BigInt``

Divide the dividend with the divisor using integer division and return the remainder.

Follows the standard Gleam divide-by-zero rule of 0 when the divisor is 0.

## remainder_no_zero

</>
``````pub fn remainder_no_zero(
dividend a: BigInt,
divisor b: BigInt,
) -> Result(BigInt, Nil)``````

Divide the dividend with the divisor using integer division and return the remainder.

Returns an error if the divisor is 0.

## subtract

</>
``````pub fn subtract(
minuend a: BigInt,
subtrahend b: BigInt,
) -> BigInt``````

Subtract the subtrahend from the minuend.

## to_int

</>
``pub fn to_int(bigint: BigInt) -> Result(Int, Nil)``

Convert the big integer to a regular integer.

In Erlang, this cannot fail, as all Erlang integers are big integers. In the JavaScript target, this will fail if the integer is bigger than the maximum safe integer or smaller than the minimum safe integer.

## to_string

</>
``pub fn to_string(bigint: BigInt) -> String``

Convert the big integer into a simple string - a sequence of digits.

## zero

</>
``pub fn zero() -> BigInt``

Create a big integer representing zero.