BigInt
Edit on GitHubUtilities for working with the BigInt type.
Added in 0.5.0
No other changes yet.
Values
Functions and constants included in the BigInt module.
BigInt.fromNumber
Added in 0.5.0
No other changes yet.
Converts a Number to a BigInt.
Parameters:
param | type | description |
---|---|---|
number |
Number |
The value to convert |
Returns:
type | description |
---|---|
BigInt |
The Number represented as a BigInt |
BigInt.toNumber
Added in 0.5.0
No other changes yet.
Converts a BigInt to a Number.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The value to convert |
Returns:
type | description |
---|---|
Number |
The BigInt represented as a Number |
BigInt.incr
Added in 0.5.0
No other changes yet.
Increments the value by one.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The value to increment |
Returns:
type | description |
---|---|
BigInt |
The incremented value |
Examples:
BigInt.decr
Added in 0.5.0
No other changes yet.
Decrements the value by one.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The value to decrement |
Returns:
type | description |
---|---|
BigInt |
The decremented value |
Examples:
BigInt.neg
Added in 0.5.0
No other changes yet.
Negates the given operand.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The operand |
Returns:
type | description |
---|---|
BigInt |
The negated operand |
Examples:
BigInt.abs
Added in 0.5.0
No other changes yet.
Returns the absolute value of the given operand.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The operand |
Returns:
type | description |
---|---|
BigInt |
The operand’s absolute value |
Examples:
BigInt.(+)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `add` |
Computes the sum of its operands.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first operand |
num2 |
BigInt |
The second operand |
Returns:
type | description |
---|---|
BigInt |
The sum of the two operands |
Examples:
BigInt.(-)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `sub` |
Computes the difference of its operands.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first operand |
num2 |
BigInt |
The second operand |
Returns:
type | description |
---|---|
BigInt |
The difference of the two operands |
Examples:
BigInt.(*)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `mul` |
Computes the product of its operands.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first operand |
num2 |
BigInt |
The second operand |
Returns:
type | description |
---|---|
BigInt |
The product of the two operands |
Examples:
BigInt.(/)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `div` |
Computes the quotient of its operands using signed (truncated) division (in which the quotient is always rounded towards zero).
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first operand |
num2 |
BigInt |
The second operand |
Returns:
type | description |
---|---|
BigInt |
The quotient of its operands |
Examples:
BigInt.rem
Added in 0.5.0
No other changes yet.
Computes the remainder of the division of its operands using signed (truncated) division (in which the quotient is always rounded towards zero).
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first operand |
num2 |
BigInt |
The second operand |
Returns:
type | description |
---|---|
BigInt |
The remainder of its operands |
Examples:
BigInt.quotRem
Added in 0.5.0
No other changes yet.
Computes the quotient and remainder of its operands using signed (truncated) division.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first operand |
num2 |
BigInt |
The second operand |
Returns:
type | description |
---|---|
(BigInt, BigInt) |
The quotient and remainder of its operands |
Examples:
BigInt.gcd
Added in 0.5.0
No other changes yet.
Computes the greatest common divisior of the two operands.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first operand |
num2 |
BigInt |
The second operand |
Returns:
type | description |
---|---|
BigInt |
The greatest common divisor of its operands |
Examples:
BigInt.(<<)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `shl` |
Shifts the bits of the value left by the given number of bits.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The value to shift |
places |
Int32 |
The number of bits to shift by |
Returns:
type | description |
---|---|
BigInt |
The shifted value |
Examples:
BigInt.(>>)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `shr` |
Shifts the bits of the value right by the given number of bits, preserving the sign bit.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The value to shift |
places |
Int32 |
The amount to shift by |
Returns:
type | description |
---|---|
BigInt |
The shifted value |
Examples:
BigInt.eqz
Added in 0.5.0
No other changes yet.
Checks if the given value is equal to zero.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The value to inspect |
Returns:
type | description |
---|---|
Bool |
true if the first value is equal to zero or false otherwise |
Examples:
BigInt.(==)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `eq` |
Checks if the first value is equal to the second value.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first value |
num2 |
BigInt |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is equal to the second value or false otherwise |
Examples:
BigInt.(!=)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `ne` |
Checks if the first value is not equal to the second value.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first value |
num2 |
BigInt |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is not equal to the second value or false otherwise |
Examples:
BigInt.(<)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `lt` |
Checks if the first value is less than the second value.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first value |
num2 |
BigInt |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is less than the second value or false otherwise |
Examples:
BigInt.(<=)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `lte` |
Checks if the first value is less than or equal to the second value.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first value |
num2 |
BigInt |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is less than or equal to the second value or false otherwise |
Examples:
BigInt.(>)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `gt` |
Checks if the first value is greater than the second value.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first value |
num2 |
BigInt |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is greater than the second value or false otherwise |
Examples:
BigInt.(>=)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `gte` |
Checks if the first value is greater than or equal to the second value.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first value |
num2 |
BigInt |
The second value |
Returns:
type | description |
---|---|
Bool |
true if the first value is greater than or equal to the second value or false otherwise |
Examples:
BigInt.lnot
Added in 0.5.0
No other changes yet.
Computes the bitwise NOT of the given value.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The given value |
Returns:
type | description |
---|---|
BigInt |
Containing the inverted bits of the given value |
Examples:
BigInt.(&)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `land` |
Computes the bitwise AND (&
) on the given operands.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first operand |
num2 |
BigInt |
The second operand |
Returns:
type | description |
---|---|
BigInt |
Containing a 1 in each bit position for which the corresponding bits of both operands are 1 |
Examples:
BigInt.(|)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `lor` |
Computes the bitwise OR (|
) on the given operands.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first operand |
num2 |
BigInt |
The second operand |
Returns:
type | description |
---|---|
BigInt |
Containing a 1 in each bit position for which the corresponding bits of either or both operands are 1 |
Examples:
BigInt.(^)
Added in 0.6.0
version | changes |
---|---|
0.5.0 | Originally named `lxor` |
Computes the bitwise XOR (^
) on the given operands.
Parameters:
param | type | description |
---|---|---|
num1 |
BigInt |
The first operand |
num2 |
BigInt |
The second operand |
Returns:
type | description |
---|---|
BigInt |
Containing a 1 in each bit position for which the corresponding bits of either but not both operands are 1 |
Examples:
BigInt.clz
Added in 0.5.0
No other changes yet.
Counts the number of leading zero bits in the value. Will return the maximum integer for negative numbers.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The value to inspect |
Returns:
type | description |
---|---|
Int32 |
The amount of leading zeros |
Examples:
BigInt.ctz
Added in 0.5.0
No other changes yet.
Counts the number of trailing zero bits in the value.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The value to inspect |
Returns:
type | description |
---|---|
Int64 |
The amount of trailing zeros |
Examples:
BigInt.popcnt
Added in 0.5.0
No other changes yet.
Counts the number of bits set to 1
in the value, also known as a population count.
Will return the None
if given a negative integer
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The value to inspect |
Returns:
type | description |
---|---|
Option<Int64> |
The amount of 1-bits in its operand |
Examples:
BigInt.toString
Added in 0.5.0
No other changes yet.
Converts the given operand to a string.
Parameters:
param | type | description |
---|---|---|
num |
BigInt |
The operand |
Returns:
type | description |
---|---|
String |
The operand, as a string |
Examples: