hickscorp/elm-bigint/1.0.2

NOTE: this package is not compatible with Elm 0.19.1

BigInt

Infinite digits integers

type BigInt

BigInt type

From/To

fromInt : Int -> BigInt

Makes an BigInt from an Int

fromString : String -> Maybe BigInt

Makes an BigInt from a Integer or Hex String, positive or negative

fromString "123" == Just (BigInt.Pos ...)
fromString "0x456" == Just (BigInt.Pos ...)
fromString "-123" == Just (BigInt.Neg ...)
fromString "-0x123" == Just (BigInt.Neg ...)
fromString "" == Nothing
fromString "0x" == Nothing
fromString "this is not a number :P" == Nothing
toString : BigInt -> String

Converts the BigInt to a String

toHexString : BigInt -> String

Print the number as a hex string.

Operations

add : BigInt -> BigInt -> BigInt

Adds two BigInts

sub : BigInt -> BigInt -> BigInt

Substracts the second BigInt from the first

mul : BigInt -> BigInt -> BigInt

Multiplies two BigInts

div : BigInt -> BigInt -> BigInt

BigInt division. Produces 0 when dividing by 0 (like (//)).

mod : BigInt -> BigInt -> BigInt

Modulus. Crashes on zero (like (%)).

divmod : BigInt -> BigInt -> Maybe ( BigInt, BigInt )

Division and modulus

pow : BigInt -> BigInt -> BigInt

Power/Exponentiation.

Sign

abs : BigInt -> BigInt

Absolute value

negate : BigInt -> BigInt

Changes the sign of an BigInt

Comparison

compare : BigInt -> BigInt -> Order

Compares two BigInts

gt : BigInt -> BigInt -> Bool

Greater than

gte : BigInt -> BigInt -> Bool

Greater than or equals

lt : BigInt -> BigInt -> Bool

Less than

lte : BigInt -> BigInt -> Bool

Less than or equals

max : BigInt -> BigInt -> BigInt

Returns the largest of two BigInts

min : BigInt -> BigInt -> BigInt

Returns the smallest of two BigInts

Misc

isEven : BigInt -> Bool

Parity Check - Even.

isOdd : BigInt -> Bool

Parity Check - Odd.