XU XUv0.16.0

#math/big

import: #math/big

counts: 3 functions, 59 methods, 3 types, 5 constants, 0 method sets

Big Int and rational Rat. No Float.

struct Int

XuAPI
pub struct Int {
    pub neg bool
    pub abs []int
}

Purpose

Structure encapsulating neg, abs.

Public fields

neg bool
field (bool)
abs []int
field ([]int)

new_int

XuAPI
pub fn new_int(x int) Int

Purpose

Construct int.

Parameters

x int
value (int)

Returns

Int — a value of this type

($&Int) set_int64

XuAPI
pub fn (z $&Int) set_int64(x int)

Purpose

Operation on $&Int: set int64.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x int
value (int)

Returns

This call does not return a value.

($&Int) set

XuAPI
pub fn (z $&Int) set(x &Int)

Purpose

Execute set on $&Int.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)

Returns

This call does not return a value.

($&Int) set_bytes

XuAPI
pub fn (z $&Int) set_bytes(buf string)

Purpose

Operation on $&Int: set bytes.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
buf string
buffer (string)

Returns

This call does not return a value.

($&Int) set_string

XuAPI
pub fn (z $&Int) set_string(s string, base0 int) int

Purpose

Operation on $&Int: set string. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
s string
source string (string)
base0 int
base0 (int)

Returns

int — a value of this type

(&Int) sign

XuAPI
pub fn (z &Int) sign() int

Purpose

Operation on &Int: compute digital signature using private key.

Parameters

z &Int
The Int instance used by this call (borrow).

Returns

int — a value of this type

(&Int) cmp

XuAPI
pub fn (z &Int) cmp(y &Int) int

Purpose

Execute cmp on &Int.

Parameters

z &Int
The Int instance used by this call (borrow).
y &Int
value (read-only borrow; caller keeps the original; type &Int)

Returns

int — a value of this type

(&Int) bit_len

XuAPI
pub fn (z &Int) bit_len() int

Purpose

Operation on &Int: bit len.

Parameters

z &Int
The Int instance used by this call (borrow).

Returns

int — a value of this type

(&Int) bit

XuAPI
pub fn (z &Int) bit(i int) int

Purpose

Execute bit on &Int.

Parameters

z &Int
The Int instance used by this call (borrow).
i int
index or integer (int)

Returns

int — a value of this type

(&Int) bytes

XuAPI
pub fn (z &Int) bytes() string

Purpose

Operation on &Int: return the buffered bytes.

Parameters

z &Int
The Int instance used by this call (borrow).

Returns

string — result string

(&Int) text

XuAPI
pub fn (z &Int) text() string

Purpose

Operation on &Int: return the current text.

Parameters

z &Int
The Int instance used by this call (borrow).

Returns

string — result string

(&Int) int64

XuAPI
pub fn (z &Int) int64() int

Purpose

Execute int64 on &Int.

Parameters

z &Int
The Int instance used by this call (borrow).

Returns

int — a value of this type

($&Int) add

XuAPI
pub fn (z $&Int) add(x &Int, y &Int)

Purpose

Operation on $&Int: add.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)
y &Int
value (read-only borrow; caller keeps the original; type &Int)

Returns

This call does not return a value.

($&Int) sub

XuAPI
pub fn (z $&Int) sub(x &Int, y &Int)

Purpose

Operation on $&Int: subtract.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)
y &Int
value (read-only borrow; caller keeps the original; type &Int)

Returns

This call does not return a value.

($&Int) mul

XuAPI
pub fn (z $&Int) mul(x &Int, y &Int)

Purpose

Operation on $&Int: multiply.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)
y &Int
value (read-only borrow; caller keeps the original; type &Int)

Returns

This call does not return a value.

($&Int) neg

XuAPI
pub fn (z $&Int) neg(x &Int)

Purpose

Execute neg on $&Int.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)

Returns

This call does not return a value.

($&Int) abs

XuAPI
pub fn (z $&Int) abs(x &Int)

Purpose

Operation on $&Int: absolute value.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)

Returns

This call does not return a value.

($&Int) lsh

XuAPI
pub fn (z $&Int) lsh(x &Int, n int)

Purpose

Execute lsh on $&Int.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)
n int
count, length, or limit (int)

Returns

This call does not return a value.

($&Int) rsh

XuAPI
pub fn (z $&Int) rsh(x &Int, n int)

Purpose

Execute rsh on $&Int.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)
n int
count, length, or limit (int)

Returns

This call does not return a value.

($&Int) quo_rem

XuAPI
pub fn (z $&Int) quo_rem(x &Int, y &Int, r $&Int) int

Purpose

Operation on $&Int: quo rem. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)
y &Int
value (read-only borrow; caller keeps the original; type &Int)
r $&Int
rune (Unicode code point) (exclusive borrow; may modify the original; type $&Int)

Returns

int — a value of this type

($&Int) quo

XuAPI
pub fn (z $&Int) quo(x &Int, y &Int) int

Purpose

Execute quo on $&Int. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)
y &Int
value (read-only borrow; caller keeps the original; type &Int)

Returns

int — a value of this type

($&Int) rem

XuAPI
pub fn (z $&Int) rem(x &Int, y &Int) int

Purpose

Execute rem on $&Int. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)
y &Int
value (read-only borrow; caller keeps the original; type &Int)

Returns

int — a value of this type

($&Int) mod

XuAPI
pub fn (z $&Int) mod(x &Int, m &Int) int

Purpose

Operation on $&Int: compute floating-point division remainder. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)
m &Int
m (read-only borrow; caller keeps the original; type &Int)

Returns

int — a value of this type

($&Int) exp

XuAPI
pub fn (z $&Int) exp(x &Int, y &Int, m &Int) int

Purpose

Operation on $&Int: e to the power. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)
y &Int
value (read-only borrow; caller keeps the original; type &Int)
m &Int
m (read-only borrow; caller keeps the original; type &Int)

Returns

int — a value of this type

($&Int) gcd

XuAPI
pub fn (z $&Int) gcd(a &Int, b &Int)

Purpose

Execute gcd on $&Int.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
a &Int
value (read-only borrow; caller keeps the original; type &Int)
b &Int
b (read-only borrow; caller keeps the original; type &Int)

Returns

This call does not return a value.

($&Int) mod_inverse

XuAPI
pub fn (z $&Int) mod_inverse(g &Int, n &Int) int

Purpose

Operation on $&Int: mod inverse. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Int
The Int instance used by this call (exclusive borrow).
g &Int
g (read-only borrow; caller keeps the original; type &Int)
n &Int
count, length, or limit (read-only borrow; caller keeps the original; type &Int)

Returns

int — a value of this type

(&Int) probably_prime

XuAPI
pub fn (x &Int) probably_prime(nchecks int) bool

Purpose

Operation on &Int: probably prime.

Parameters

x &Int
The Int instance used by this call (borrow).
nchecks int
nchecks (int)

Returns

bool — true or false

struct Rat

XuAPI
pub struct Rat {

}

Purpose

Rat context or state structure.

Public fields

This type has no public fields.

new_rat

XuAPI
pub fn new_rat(a int, b int) Rat

Purpose

Construct rat.

Parameters

a int
value (int)
b int
b (int)

Returns

Rat — a value of this type

($&Rat) set_frac

XuAPI
pub fn (z $&Rat) set_frac(a &Int, b &Int) int

Purpose

Operation on $&Rat: set frac. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Rat
The Rat instance used by this call (exclusive borrow).
a &Int
value (read-only borrow; caller keeps the original; type &Int)
b &Int
b (read-only borrow; caller keeps the original; type &Int)

Returns

int — a value of this type

(&Rat) num

XuAPI
pub fn (z &Rat) num() Int

Purpose

Execute num on &Rat.

Parameters

z &Rat
The Rat instance used by this call (borrow).

Returns

Int — a value of this type

(&Rat) denom

XuAPI
pub fn (z &Rat) denom() Int

Purpose

Execute denom on &Rat.

Parameters

z &Rat
The Rat instance used by this call (borrow).

Returns

Int — a value of this type

(&Rat) sign

XuAPI
pub fn (z &Rat) sign() int

Purpose

Operation on &Rat: compute digital signature using private key.

Parameters

z &Rat
The Rat instance used by this call (borrow).

Returns

int — a value of this type

($&Rat) add

XuAPI
pub fn (z $&Rat) add(x &Rat, y &Rat)

Purpose

Operation on $&Rat: add.

Parameters

z $&Rat
The Rat instance used by this call (exclusive borrow).
x &Rat
value (read-only borrow; caller keeps the original; type &Rat)
y &Rat
value (read-only borrow; caller keeps the original; type &Rat)

Returns

This call does not return a value.

($&Rat) sub

XuAPI
pub fn (z $&Rat) sub(x &Rat, y &Rat)

Purpose

Operation on $&Rat: subtract.

Parameters

z $&Rat
The Rat instance used by this call (exclusive borrow).
x &Rat
value (read-only borrow; caller keeps the original; type &Rat)
y &Rat
value (read-only borrow; caller keeps the original; type &Rat)

Returns

This call does not return a value.

($&Rat) mul

XuAPI
pub fn (z $&Rat) mul(x &Rat, y &Rat)

Purpose

Operation on $&Rat: multiply.

Parameters

z $&Rat
The Rat instance used by this call (exclusive borrow).
x &Rat
value (read-only borrow; caller keeps the original; type &Rat)
y &Rat
value (read-only borrow; caller keeps the original; type &Rat)

Returns

This call does not return a value.

($&Rat) quo

XuAPI
pub fn (z $&Rat) quo(x &Rat, y &Rat) int

Purpose

Execute quo on $&Rat. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Rat
The Rat instance used by this call (exclusive borrow).
x &Rat
value (read-only borrow; caller keeps the original; type &Rat)
y &Rat
value (read-only borrow; caller keeps the original; type &Rat)

Returns

int — a value of this type

const TO_ZERO

XuAPI
pub const TO_ZERO = 0

Purpose

Constant TO_ZERO, defining protocol or algorithm parameters.

const TO_NEAREST_EVEN

XuAPI
pub const TO_NEAREST_EVEN = 1

Purpose

Constant TO_NEAREST_EVEN, defining protocol or algorithm parameters.

const TO_NEG_INF

XuAPI
pub const TO_NEG_INF = 2

Purpose

Constant TO_NEG_INF, defining protocol or algorithm parameters.

const TO_POS_INF

XuAPI
pub const TO_POS_INF = 3

Purpose

Constant TO_POS_INF, defining protocol or algorithm parameters.

const AWAY_FROM_ZERO

XuAPI
pub const AWAY_FROM_ZERO = 4

Purpose

Constant AWAY_FROM_ZERO, defining protocol or algorithm parameters.

struct Float

XuAPI
pub struct Float {
    pub prec int
    pub neg bool
    pub mant Int
    pub exp int
    pub form int
    pub mode int
}

Purpose

Structure encapsulating prec, neg, mant, exp, form.

Public fields

prec int
precision
neg bool
field (bool)
mant Int
field (Int)
exp int
field (int)
form int
field (int)
mode int
mode

new_float

XuAPI
pub fn new_float() Float

Purpose

Construct float.

Parameters

No arguments are required.

Returns

Float — a value of this type

($&Float) set_prec

XuAPI
pub fn (z $&Float) set_prec(p int)

Purpose

Operation on $&Float: set prec.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
p int
p (int)

Returns

This call does not return a value.

(&Float) precision

XuAPI
pub fn (z &Float) precision() int

Purpose

Execute precision on &Float.

Parameters

z &Float
The Float instance used by this call (borrow).

Returns

int — a value of this type

($&Float) set_mode

XuAPI
pub fn (z $&Float) set_mode(m int)

Purpose

Operation on $&Float: set mode.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
m int
m (int)

Returns

This call does not return a value.

(&Float) rounding

XuAPI
pub fn (z &Float) rounding() int

Purpose

Execute rounding on &Float.

Parameters

z &Float
The Float instance used by this call (borrow).

Returns

int — a value of this type

($&Float) set_inf

XuAPI
pub fn (z $&Float) set_inf(neg bool)

Purpose

Operation on $&Float: set inf.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
neg bool
neg (bool)

Returns

This call does not return a value.

($&Float) set_nan

XuAPI
pub fn (z $&Float) set_nan()

Purpose

Operation on $&Float: set nan.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).

Returns

This call does not return a value.

(&Float) is_inf

XuAPI
pub fn (z &Float) is_inf() bool

Purpose

Operation on &Float: whether the value is infinity.

Parameters

z &Float
The Float instance used by this call (borrow).

Returns

bool — true or false

(&Float) is_nan

XuAPI
pub fn (z &Float) is_nan() bool

Purpose

Operation on &Float: whether the value is NaN.

Parameters

z &Float
The Float instance used by this call (borrow).

Returns

bool — true or false

($&Float) set

XuAPI
pub fn (z $&Float) set(x &Float)

Purpose

Execute set on $&Float.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
x &Float
value (read-only borrow; caller keeps the original; type &Float)

Returns

This call does not return a value.

($&Float) set_int64

XuAPI
pub fn (z $&Float) set_int64(x int)

Purpose

Operation on $&Float: set int64.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
x int
value (int)

Returns

This call does not return a value.

($&Float) set_int

XuAPI
pub fn (z $&Float) set_int(x &Int)

Purpose

Operation on $&Float: set int.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
x &Int
value (read-only borrow; caller keeps the original; type &Int)

Returns

This call does not return a value.

(&Float) to_int64

XuAPI
pub fn (z &Float) to_int64() int

Purpose

Operation on &Float: convert to int64. Throws on failure; handle the error or propagate it to the caller.

Parameters

z &Float
The Float instance used by this call (borrow).

Returns

int — a value of this type

(&Float) signbit

XuAPI
pub fn (z &Float) signbit() bool

Purpose

Execute signbit on &Float.

Parameters

z &Float
The Float instance used by this call (borrow).

Returns

bool — true or false

(&Float) unbiased_exp

XuAPI
pub fn (z &Float) unbiased_exp() int

Purpose

Operation on &Float: unbiased exp.

Parameters

z &Float
The Float instance used by this call (borrow).

Returns

int — a value of this type

(&Float) mantissa

XuAPI
pub fn (z &Float) mantissa() Float

Purpose

Execute mantissa on &Float.

Parameters

z &Float
The Float instance used by this call (borrow).

Returns

Float — a value of this type

($&Float) set_mant_exp

XuAPI
pub fn (z $&Float) set_mant_exp(mant &Float, exp int)

Purpose

Operation on $&Float: set mant exp.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
mant &Float
mant (read-only borrow; caller keeps the original; type &Float)
exp int
exp (int)

Returns

This call does not return a value.

(&Float) sign

XuAPI
pub fn (z &Float) sign() int

Purpose

Operation on &Float: compute digital signature using private key.

Parameters

z &Float
The Float instance used by this call (borrow).

Returns

int — a value of this type

(&Float) cmp

XuAPI
pub fn (z &Float) cmp(y &Float) int

Purpose

Execute cmp on &Float. Throws on failure; handle the error or propagate it to the caller.

Parameters

z &Float
The Float instance used by this call (borrow).
y &Float
value (read-only borrow; caller keeps the original; type &Float)

Returns

int — a value of this type

($&Float) add

XuAPI
pub fn (z $&Float) add(x &Float, y &Float)

Purpose

Operation on $&Float: add.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
x &Float
value (read-only borrow; caller keeps the original; type &Float)
y &Float
value (read-only borrow; caller keeps the original; type &Float)

Returns

This call does not return a value.

($&Float) sub

XuAPI
pub fn (z $&Float) sub(x &Float, y &Float)

Purpose

Operation on $&Float: subtract.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
x &Float
value (read-only borrow; caller keeps the original; type &Float)
y &Float
value (read-only borrow; caller keeps the original; type &Float)

Returns

This call does not return a value.

($&Float) mul

XuAPI
pub fn (z $&Float) mul(x &Float, y &Float)

Purpose

Operation on $&Float: multiply.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
x &Float
value (read-only borrow; caller keeps the original; type &Float)
y &Float
value (read-only borrow; caller keeps the original; type &Float)

Returns

This call does not return a value.

($&Float) quo

XuAPI
pub fn (z $&Float) quo(x &Float, y &Float) int

Purpose

Execute quo on $&Float. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
x &Float
value (read-only borrow; caller keeps the original; type &Float)
y &Float
value (read-only borrow; caller keeps the original; type &Float)

Returns

int — a value of this type

(&Float) text

XuAPI
pub fn (z &Float) text() string

Purpose

Operation on &Float: return the current text.

Parameters

z &Float
The Float instance used by this call (borrow).

Returns

string — result string

($&Float) set_string

XuAPI
pub fn (z $&Float) set_string(s string) int

Purpose

Operation on $&Float: set string. Throws on failure; handle the error or propagate it to the caller.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
s string
source string (string)

Returns

int — a value of this type

($&Float) set_float64

XuAPI
pub fn (z $&Float) set_float64(x f64) int

Purpose

Operation on $&Float: set float64.

Parameters

z $&Float
The Float instance used by this call (exclusive borrow).
x f64
value (f64)

Returns

int — a value of this type