XU XUv0.8.8
中文

API

#math/big

import: #math/big

counts: 3 fns, 58 methods, 3 types, 5 consts, 0 ifaces

Big Int and rational Rat. No Float.

struct Int

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

Purpose

Public struct `Int`.

Parameters

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

(&mut Int) set_int64

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

Purpose

Method on `&mut Int`: set int64.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x int
value (int)

(&mut Int) set

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

Purpose

Call `set` on `&mut Int`.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)

(&mut Int) set_bytes

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

Purpose

Method on `&mut Int`: set bytes.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
buf string
buffer (string)

(&mut Int) set_string

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

Purpose

Method on `&mut Int`: set string. Throws on failure.

Parameters

z &mut Int
receiver &mut Int (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

Method on `&Int`: sign.

Parameters

z &Int
receiver &Int (borrow)

Returns

int — a value of this type

(&Int) cmp

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

Purpose

Call `cmp` on `&Int`.

Parameters

z &Int
receiver &Int (borrow)
y &Int
value (borrowed; caller keeps it; type &Int)

Returns

int — a value of this type

(&Int) bit_len

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

Purpose

Method on `&Int`: bit len.

Parameters

z &Int
receiver &Int (borrow)

Returns

int — a value of this type

(&Int) bit

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

Purpose

Call `bit` on `&Int`.

Parameters

z &Int
receiver &Int (borrow)
i int
index or integer (int)

Returns

int — a value of this type

(&Int) bytes

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

Purpose

Method on `&Int`: return the buffered bytes.

Parameters

z &Int
receiver &Int (borrow)

Returns

string — result string

(&Int) text

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

Purpose

Method on `&Int`: return the current text.

Parameters

z &Int
receiver &Int (borrow)

Returns

string — result string

(&Int) int64

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

Purpose

Call `int64` on `&Int`.

Parameters

z &Int
receiver &Int (borrow)

Returns

int — a value of this type

(&mut Int) add

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

Purpose

Method on `&mut Int`: add.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)
y &Int
value (borrowed; caller keeps it; type &Int)

(&mut Int) sub

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

Purpose

Method on `&mut Int`: subtract.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)
y &Int
value (borrowed; caller keeps it; type &Int)

(&mut Int) mul

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

Purpose

Method on `&mut Int`: multiply.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)
y &Int
value (borrowed; caller keeps it; type &Int)

(&mut Int) neg

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

Purpose

Call `neg` on `&mut Int`.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)

(&mut Int) abs

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

Purpose

Method on `&mut Int`: absolute value.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)

(&mut Int) lsh

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

Purpose

Call `lsh` on `&mut Int`.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)
n int
count, length, or limit (int)

(&mut Int) rsh

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

Purpose

Call `rsh` on `&mut Int`.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)
n int
count, length, or limit (int)

(&mut Int) quo

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

Purpose

Call `quo` on `&mut Int`. Throws on failure.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)
y &Int
value (borrowed; caller keeps it; type &Int)

Returns

int — a value of this type

(&mut Int) rem

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

Purpose

Call `rem` on `&mut Int`. Throws on failure.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)
y &Int
value (borrowed; caller keeps it; type &Int)

Returns

int — a value of this type

(&mut Int) mod

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

Purpose

Method on `&mut Int`: modulo. Throws on failure.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)
m &Int
m (borrowed; caller keeps it; type &Int)

Returns

int — a value of this type

(&mut Int) exp

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

Purpose

Method on `&mut Int`: e to the power. Throws on failure.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)
y &Int
value (borrowed; caller keeps it; type &Int)
m &Int
m (borrowed; caller keeps it; type &Int)

Returns

int — a value of this type

(&mut Int) gcd

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

Purpose

Call `gcd` on `&mut Int`.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
a &Int
value (borrowed; caller keeps it; type &Int)
b &Int
b (borrowed; caller keeps it; type &Int)

(&mut Int) mod_inverse

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

Purpose

Method on `&mut Int`: mod inverse. Throws on failure.

Parameters

z &mut Int
receiver &mut Int (exclusive borrow)
g &Int
g (borrowed; caller keeps it; type &Int)
n &Int
count, length, or limit (borrowed; caller keeps it; type &Int)

Returns

int — a value of this type

(&Int) probably_prime

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

Purpose

Method on `&Int`: probably prime.

Parameters

x &Int
receiver &Int (borrow)
nchecks int
nchecks (int)

Returns

bool — true or false

struct Rat

XuAPI
pub struct Rat {

}

Purpose

Public struct `Rat`.

Parameters

none

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

(&mut Rat) set_frac

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

Purpose

Method on `&mut Rat`: set frac. Throws on failure.

Parameters

z &mut Rat
receiver &mut Rat (exclusive borrow)
a &Int
value (borrowed; caller keeps it; type &Int)
b &Int
b (borrowed; caller keeps it; type &Int)

Returns

int — a value of this type

(&Rat) num

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

Purpose

Call `num` on `&Rat`.

Parameters

z &Rat
receiver &Rat (borrow)

Returns

Int — a value of this type

(&Rat) denom

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

Purpose

Call `denom` on `&Rat`.

Parameters

z &Rat
receiver &Rat (borrow)

Returns

Int — a value of this type

(&Rat) sign

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

Purpose

Method on `&Rat`: sign.

Parameters

z &Rat
receiver &Rat (borrow)

Returns

int — a value of this type

(&mut Rat) add

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

Purpose

Method on `&mut Rat`: add.

Parameters

z &mut Rat
receiver &mut Rat (exclusive borrow)
x &Rat
value (borrowed; caller keeps it; type &Rat)
y &Rat
value (borrowed; caller keeps it; type &Rat)

(&mut Rat) sub

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

Purpose

Method on `&mut Rat`: subtract.

Parameters

z &mut Rat
receiver &mut Rat (exclusive borrow)
x &Rat
value (borrowed; caller keeps it; type &Rat)
y &Rat
value (borrowed; caller keeps it; type &Rat)

(&mut Rat) mul

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

Purpose

Method on `&mut Rat`: multiply.

Parameters

z &mut Rat
receiver &mut Rat (exclusive borrow)
x &Rat
value (borrowed; caller keeps it; type &Rat)
y &Rat
value (borrowed; caller keeps it; type &Rat)

(&mut Rat) quo

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

Purpose

Call `quo` on `&mut Rat`. Throws on failure.

Parameters

z &mut Rat
receiver &mut Rat (exclusive borrow)
x &Rat
value (borrowed; caller keeps it; type &Rat)
y &Rat
value (borrowed; caller keeps it; type &Rat)

Returns

int — a value of this type

const to_zero

XuAPI
pub const to_zero = 0

Purpose

`math/big.Float` subset. A finite value is ±mant·2^exp with `prec` significant bits (default 53, max 4096). Also +Inf/-Inf/NaN. Rounding: to_zero (default), to_nearest_even, to_neg_inf, to_pos_inf, away_from_zero. Methods mutate the receiver like Int. Value `0`.

Parameters

none

const to_nearest_even

XuAPI
pub const to_nearest_even = 1

Purpose

Public constant `to_nearest_even`. Value `1`.

Parameters

none

const to_neg_inf

XuAPI
pub const to_neg_inf = 2

Purpose

Public constant `to_neg_inf`. Value `2`.

Parameters

none

const to_pos_inf

XuAPI
pub const to_pos_inf = 3

Purpose

Public constant `to_pos_inf`. Value `3`.

Parameters

none

const away_from_zero

XuAPI
pub const away_from_zero = 4

Purpose

Public constant `away_from_zero`. Value `4`.

Parameters

none

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

Public struct `Float`.

Parameters

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

none

Returns

Float — a value of this type

(&mut Float) set_prec

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

Purpose

Method on `&mut Float`: set prec.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
p int
p (int)

(&Float) precision

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

Purpose

Call `precision` on `&Float`.

Parameters

z &Float
receiver &Float (borrow)

Returns

int — a value of this type

(&mut Float) set_mode

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

Purpose

Method on `&mut Float`: set mode.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
m int
m (int)

(&Float) rounding

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

Purpose

Call `rounding` on `&Float`.

Parameters

z &Float
receiver &Float (borrow)

Returns

int — a value of this type

(&mut Float) set_inf

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

Purpose

Method on `&mut Float`: set inf.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
neg bool
neg (bool)

(&mut Float) set_nan

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

Purpose

Method on `&mut Float`: set nan.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)

(&Float) is_inf

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

Purpose

Method on `&Float`: whether the value is infinity.

Parameters

z &Float
receiver &Float (borrow)

Returns

bool — true or false

(&Float) is_nan

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

Purpose

Method on `&Float`: whether the value is NaN.

Parameters

z &Float
receiver &Float (borrow)

Returns

bool — true or false

(&mut Float) set

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

Purpose

Call `set` on `&mut Float`.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
x &Float
value (borrowed; caller keeps it; type &Float)

(&mut Float) set_int64

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

Purpose

Method on `&mut Float`: set int64.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
x int
value (int)

(&mut Float) set_int

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

Purpose

Method on `&mut Float`: set int.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
x &Int
value (borrowed; caller keeps it; type &Int)

(&Float) to_int64

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

Purpose

Method on `&Float`: convert to int64. Throws on failure.

Parameters

z &Float
receiver &Float (borrow)

Returns

int — a value of this type

(&Float) signbit

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

Purpose

Call `signbit` on `&Float`.

Parameters

z &Float
receiver &Float (borrow)

Returns

bool — true or false

(&Float) unbiased_exp

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

Purpose

Method on `&Float`: unbiased exp.

Parameters

z &Float
receiver &Float (borrow)

Returns

int — a value of this type

(&Float) mantissa

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

Purpose

Call `mantissa` on `&Float`.

Parameters

z &Float
receiver &Float (borrow)

Returns

Float — a value of this type

(&mut Float) set_mant_exp

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

Purpose

Method on `&mut Float`: set mant exp.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
mant &Float
mant (borrowed; caller keeps it; type &Float)
exp int
exp (int)

(&Float) sign

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

Purpose

Method on `&Float`: sign.

Parameters

z &Float
receiver &Float (borrow)

Returns

int — a value of this type

(&Float) cmp

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

Purpose

Call `cmp` on `&Float`. Throws on failure.

Parameters

z &Float
receiver &Float (borrow)
y &Float
value (borrowed; caller keeps it; type &Float)

Returns

int — a value of this type

(&mut Float) add

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

Purpose

Method on `&mut Float`: add.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
x &Float
value (borrowed; caller keeps it; type &Float)
y &Float
value (borrowed; caller keeps it; type &Float)

(&mut Float) sub

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

Purpose

Method on `&mut Float`: subtract.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
x &Float
value (borrowed; caller keeps it; type &Float)
y &Float
value (borrowed; caller keeps it; type &Float)

(&mut Float) mul

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

Purpose

Method on `&mut Float`: multiply.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
x &Float
value (borrowed; caller keeps it; type &Float)
y &Float
value (borrowed; caller keeps it; type &Float)

(&mut Float) quo

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

Purpose

Call `quo` on `&mut Float`. Throws on failure.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
x &Float
value (borrowed; caller keeps it; type &Float)
y &Float
value (borrowed; caller keeps it; type &Float)

Returns

int — a value of this type

(&Float) text

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

Purpose

Method on `&Float`: return the current text.

Parameters

z &Float
receiver &Float (borrow)

Returns

string — result string

(&mut Float) set_string

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

Purpose

Method on `&mut Float`: set string. Throws on failure.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
s string
source string (string)

Returns

int — a value of this type

(&mut Float) set_float64

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

Purpose

Method on `&mut Float`: set float64. Throws on failure.

Parameters

z &mut Float
receiver &mut Float (exclusive borrow)
x f64
value (f64)

Returns

int — a value of this type