x-lang

← Index

x/num/bigint

Arbitrary-precision integers, homed on the Bigint class.

Auto-promotes when integers exceed native range; the generic operators

dispatch bigint operands through the type ops. API: (Bigint + a b), …

Predicates

Arithmetic

Comparison

Operator Overrides

+

Add numbers, promoting to bigint on overflow.

Parameters:

Returns: INT|BIGINT — Sum

-

Subtract numbers, promoting to bigint on overflow. Unary form negates.

Parameters:

Returns: INT|BIGINT — Difference

*

Multiply numbers, promoting to bigint on overflow.

Parameters:

Returns: INT|BIGINT — Product

/

Divide numbers; bigint operands dispatch through the type ops.

Parameters:

Returns: INT|BIGINT — Quotient

Class Bigint

(Bigint bigint? x)

Test whether a value is an arbitrary-precision integer.

Parameters:

Returns: BOOL — True if x is a bigint

(Bigint + a b)

Add two bigints (ints coerce).

Parameters:

Returns: INT|BIGINT — Sum, demoted to integer if it fits

(Bigint - a b)

Subtract two bigints (ints coerce).

Parameters:

Returns: INT|BIGINT — Difference, demoted to integer if it fits

(Bigint * a b)

Multiply two bigints (ints coerce).

Parameters:

Returns: INT|BIGINT — Product, demoted to integer if it fits

(Bigint / a b)

Divide two bigints (truncating; ints coerce).

Parameters:

Returns: INT|BIGINT — Quotient, demoted to integer if it fits

(Bigint % a b)

Remainder of bigint division (ints coerce).

Parameters:

Returns: INT|BIGINT — Remainder, demoted to integer if it fits

(Bigint < a b)

Test whether a is less than b (ints coerce).

Parameters:

Returns: BOOL — True if a < b

(Bigint = a b)

Test whether a equals b (ints coerce).

Parameters:

Returns: BOOL — True if a equals b

(Bigint would-overflow-add? a b)

Test whether addition of two native integers would overflow.

Parameters:

Returns: BOOL — True if a + b would overflow native integer

(Bigint would-overflow-mul? a b)

Test whether multiplication of two native integers would overflow.

Parameters:

Returns: BOOL — True if a * b would overflow native integer