math.big #

fn b_and #

fn b_and(a &Number, b &Number) Number

//////////////////////////////////////////////////////////

fn b_or #

fn b_or(a &Number, b &Number) Number

fn b_xor #

fn b_xor(a &Number, b &Number) Number

fn cmp #

fn cmp(a &Number, b &Number) int

//////////////////////////////////////////////////////////

fn divmod #

fn divmod(a &Number, b &Number, c &Number) Number

fn fact #

fn fact(n int) Number

fn factorial #

fn factorial(nn &Number) Number

//////////////////////////////////////////////////////////

fn from_hex_string #

fn from_hex_string(input string) Number

from_hex_string converts a hex string to big.Number

fn from_int #

fn from_int(i int) Number

conversion actions to/from big numbers: from_int converts an ordinary int number i to big.Number

fn from_string #

fn from_string(input string) Number

from_string converts a decimal string to big.Number

fn from_u64 #

fn from_u64(u u64) Number

from_u64 converts an ordinary u64 number u to big.Number

fn new #

fn new() Number

fn pow #

fn pow(a &Number, b &Number) Number

fn (Number) int #

fn (n &Number) int() int

.int() converts (a small) big.Number n to an ordinary integer.

fn (Number) str #

fn (n &Number) str() string

.str returns a decimal representation of the big unsigned integer number n.

fn (Number) hexstr #

fn (n &Number) hexstr() string

.hexstr returns a hexadecimal representation of the bignum n

fn (Number) + #

fn (a &Number) + (b &Number) Number

////////////////////////////////////////////////////////// overloaded ops for the numbers:

fn (Number) - #

fn (a &Number) - (b &Number) Number

fn (Number) * #

fn (a &Number) * (b &Number) Number

fn (Number) / #

fn (a &Number) / (b &Number) Number

fn (Number) % #

fn (a &Number) % (b &Number) Number

fn (Number) is_zero #

fn (a &Number) is_zero() bool

fn (Number) inc #

fn (mut a Number) inc()

fn (Number) dec #

fn (mut a Number) dec()

fn (Number) isqrt #

fn (a &Number) isqrt() Number

fn (Number) lshift #

fn (a &Number) lshift(nbits int) Number

fn (Number) rshift #

fn (a &Number) rshift(nbits int) Number

fn (Number) clone #

fn (a &Number) clone() Number

fn (Number) bytes #

fn (n &Number) bytes() []byte

bytes returns an array of the bytes for the number n, in little endian format, where .bytes()[0] is the least significant byte. The result is NOT trimmed, and will contain 0s, even after the significant bytes. This method is faster than .bytes_trimmed(), but may be less convenient.

Examples

assert big.from_int(1).bytes()[0] == byte(0x01)
assert big.from_int(1024).bytes()[1] == byte(0x04)
assert big.from_int(1048576).bytes()[2] == byte(0x10)

fn (Number) bytes_trimmed #

fn (n &Number) bytes_trimmed() []byte

bytes_trimmed returns an array of the bytes for the number n, in little endian format, where .bytes_trimmed()[0] is the least significant byte. The result is trimmed, so that the last byte of the result is also the the last meaningfull byte, != 0 .

Examples

assert big.from_int(1).bytes_trimmed() == [byte(0x01)]
assert big.from_int(1024).bytes_trimmed() == [byte(0x00), 0x04]
assert big.from_int(1048576).bytes_trimmed() == [byte(0x00), 0x00, 0x10]