Infinite digits integers
fromInt : Basics.Int -> BigInt
Makes a BigInt from an Int
fromIntString : String -> Maybe BigInt
Makes a BigInt from an integer string, positive or negative
fromIntString "123" == Just (BigInt.Pos ...)
fromIntString "-123" == Just (BigInt.Neg ...)
fromIntString "" == Nothing
fromIntString "this is not a number :P" == Nothing
fromHexString : String -> Maybe BigInt
Makes a BigInt from a base16 hex string, positive or negative.
fromHexString "4b6" == Just (BigInt.Pos ...)
fromHexString "-13d" == Just (BigInt.Neg ...)
fromHexString "0x456" == Just (BigInt.Pos ...)
fromHexString "-0x123" == Just (BigInt.Neg ...)
fromHexString "R2D2" == Nothing
fromHexString "0xC3P0" == Nothing
fromHexString "0x" == Nothing
fromHexString "" == Nothing
Note: String can be prepended with or without any combination of "0x", and "+" or "-".
toString : BigInt -> String
Convert the BigInt to an integer string
toHexString : BigInt -> String
Convert the BigInt to a hex string.
toHexString (BigInt.fromInt 255) == "ff"
Note: "0x" will NOT be prepended to the output.
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 (//)).
modBy : BigInt -> BigInt -> Maybe BigInt
Modulus.
modBy (BigInt.fromInt 3) (BigInt.fromInt 3)
divmod : BigInt -> BigInt -> Maybe ( BigInt, BigInt )
Division and modulus
pow : BigInt -> BigInt -> BigInt
Power/Exponentiation.
abs : BigInt -> BigInt
Absolute value
negate : BigInt -> BigInt
Changes the sign of an BigInt
compare : BigInt -> BigInt -> Basics.Order
Compares two BigInts
gt : BigInt -> BigInt -> Basics.Bool
Greater than
gte : BigInt -> BigInt -> Basics.Bool
Greater than or equals
lt : BigInt -> BigInt -> Basics.Bool
Less than
lte : BigInt -> BigInt -> Basics.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
isEven : BigInt -> Basics.Bool
Parity Check - Even.
isOdd : BigInt -> Basics.Bool
Parity Check - Odd.