Link Search Menu Expand Document

BigInt

Table of contents

  1. BigInt
    1. BigInt.new() -> Result<BigInt>
    2. bigInt1.compare(bigInt2) -> Number
    3. bigIntVal.negate() -> Result<BigInt>
    4. bigIntVal.abs() -> Result<BigInt>
    5. bigIntVal1.bitwiseAnd() -> Result<BigInt>
    6. bigIntVal1.bitwiseOr() -> Result<BigInt>
    7. bigIntVal1.bitwiseXor() -> Result<BigInt>
    8. bigIntVal.add() -> Result<BigInt>
    9. bigIntVal.subtract() -> Result<BigInt>
    10. bigIntVal.multiply() -> Result<BigInt>
    11. bigIntVal.divide() -> Result<BigInt>
    12. bigIntVal.modulo() -> Result<BigInt>

BigInt

To make use of the BigInt module an import is required.

import BigInt;

BigInt.new() -> Result<BigInt>

Returns a Result value with a BigInt or an error. Takes 0 or 1 argument of either Number or String. If no argument is given, the returned BigInt value is set to 0.

const bi = BigInt.new().unwrap();
print(bi);
// 0
const bi = BigInt.new(8675309).unwrap();
print(bi);
// 8675309
const bi = BigInt.new("678").unwrap();
print(bi);
// 678

bigInt1.compare(bigInt2) -> Number

Returns a Number value of either 0 indicating the 2 BigInts compared are the same and -1 if the values are different.

const bi1 = BigInt.new(10).unwrap();
const bi2 = BigInt.new(10).unwrap();
const value = bi1.compare(bi2);

print(value);
// 0

bigIntVal.negate() -> Result<BigInt>

Returns a Result value that unwraps to the negated BigInt value.

const bi = BigInt.new(10).unwrap();

const value = bi1.negate();
print(value);
// -10

bigIntVal.abs() -> Result<BigInt>

Returns a Result containing the absolute value of the BigInt.

const bi = BigInt.new(10).unwrap();

const value = bi1.abs();
print(value);
// 10

bigIntVal1.bitwiseAnd() -> Result<BigInt>

Returns a Result containing the value of bigIntVal1 & bigIntVal2.

const bi1 = BigInt.new(102216).unwrap();
const bi2 = BigInt.new(8909).unwrap();

const value = bi1.bitwiseAnd(bi2);
print(value);
// 584

bigIntVal1.bitwiseOr() -> Result<BigInt>

Returns a Result containing the value of bigIntVal1 | bigIntVal2.

const bi1 = BigInt.new(102216).unwrap();
const bi2 = BigInt.new(8909).unwrap();

const value = bi1.bitwiseOr(bi2);
print(value);
// 110541

bigIntVal1.bitwiseXor() -> Result<BigInt>

Returns a Result containing the value of bigIntVal1 ^ bigIntVal2.

const bi1 = BigInt.new(102216).unwrap();
const bi2 = BigInt.new(8909).unwrap();

const value = bi1.bitwiseXor(bi2);
print(value);
// 109957

bigIntVal.add() -> Result<BigInt>

Returns a Result value containing the sum.

const bi = BigInt.new(10).unwrap();

const value = bi1.add();
print(value);
// 10

bigIntVal.subtract() -> Result<BigInt>

Returns a Result value containing the difference.

const bi = BigInt.new(10).unwrap();

const value = bi1.subtract();
print(value);
// 10

bigIntVal.multiply() -> Result<BigInt>

Returns a Result value containing the product.

const bi = BigInt.new(10).unwrap();

const value = bi1.multiply();
print(value);
// 10

bigIntVal.divide() -> Result<BigInt>

Returns a Result value containing the quotiant.

const bi = BigInt.new(10).unwrap();

const value = bi1.divide();
print(value);
// 10

bigIntVal.modulo() -> Result<BigInt>

Returns a Result value containing the remainder.

const bi = BigInt.new(10).unwrap();

const value = bi1.modulo();
print(value);
// 10

This site uses Just The Docs, with modifications.