struct Int
pub struct Int {
pub neg bool
pub abs []int
}Purpose
Public struct `Int`.
Parameters
negbool- field (bool)
abs[]int- field ([]int)
API
#math/bigBig Int and rational Rat. No Float.
struct Intpub struct Int {
pub neg bool
pub abs []int
}Public struct `Int`.
neg boolabs []intnew_intpub fn new_int(x int) IntConstruct int.
x intInt — a value of this type
(&mut Int) set_int64pub fn (z &mut Int) set_int64(x int)Method on `&mut Int`: set int64.
z &mut Intx int(&mut Int) setpub fn (z &mut Int) set(x &Int)Call `set` on `&mut Int`.
z &mut Intx &Int(&mut Int) set_bytespub fn (z &mut Int) set_bytes(buf string)Method on `&mut Int`: set bytes.
z &mut Intbuf string(&mut Int) set_stringpub fn (z &mut Int) set_string(s string, base0 int) intMethod on `&mut Int`: set string. Throws on failure.
z &mut Ints stringbase0 intint — a value of this type
(&Int) signpub fn (z &Int) sign() intMethod on `&Int`: sign.
z &Intint — a value of this type
(&Int) cmppub fn (z &Int) cmp(y &Int) intCall `cmp` on `&Int`.
z &Inty &Intint — a value of this type
(&Int) bit_lenpub fn (z &Int) bit_len() intMethod on `&Int`: bit len.
z &Intint — a value of this type
(&Int) bitpub fn (z &Int) bit(i int) intCall `bit` on `&Int`.
z &Inti intint — a value of this type
(&Int) bytespub fn (z &Int) bytes() stringMethod on `&Int`: return the buffered bytes.
z &Intstring — result string
(&Int) textpub fn (z &Int) text() stringMethod on `&Int`: return the current text.
z &Intstring — result string
(&Int) int64pub fn (z &Int) int64() intCall `int64` on `&Int`.
z &Intint — a value of this type
(&mut Int) addpub fn (z &mut Int) add(x &Int, y &Int)Method on `&mut Int`: add.
z &mut Intx &Inty &Int(&mut Int) subpub fn (z &mut Int) sub(x &Int, y &Int)Method on `&mut Int`: subtract.
z &mut Intx &Inty &Int(&mut Int) mulpub fn (z &mut Int) mul(x &Int, y &Int)Method on `&mut Int`: multiply.
z &mut Intx &Inty &Int(&mut Int) negpub fn (z &mut Int) neg(x &Int)Call `neg` on `&mut Int`.
z &mut Intx &Int(&mut Int) abspub fn (z &mut Int) abs(x &Int)Method on `&mut Int`: absolute value.
z &mut Intx &Int(&mut Int) lshpub fn (z &mut Int) lsh(x &Int, n int)Call `lsh` on `&mut Int`.
z &mut Intx &Intn int(&mut Int) rshpub fn (z &mut Int) rsh(x &Int, n int)Call `rsh` on `&mut Int`.
z &mut Intx &Intn int(&mut Int) quopub fn (z &mut Int) quo(x &Int, y &Int) intCall `quo` on `&mut Int`. Throws on failure.
z &mut Intx &Inty &Intint — a value of this type
(&mut Int) rempub fn (z &mut Int) rem(x &Int, y &Int) intCall `rem` on `&mut Int`. Throws on failure.
z &mut Intx &Inty &Intint — a value of this type
(&mut Int) modpub fn (z &mut Int) mod(x &Int, m &Int) intMethod on `&mut Int`: modulo. Throws on failure.
z &mut Intx &Intm &Intint — a value of this type
(&mut Int) exppub fn (z &mut Int) exp(x &Int, y &Int, m &Int) intMethod on `&mut Int`: e to the power. Throws on failure.
z &mut Intx &Inty &Intm &Intint — a value of this type
(&mut Int) gcdpub fn (z &mut Int) gcd(a &Int, b &Int)Call `gcd` on `&mut Int`.
z &mut Inta &Intb &Int(&mut Int) mod_inversepub fn (z &mut Int) mod_inverse(g &Int, n &Int) intMethod on `&mut Int`: mod inverse. Throws on failure.
z &mut Intg &Intn &Intint — a value of this type
(&Int) probably_primepub fn (x &Int) probably_prime(nchecks int) boolMethod on `&Int`: probably prime.
x &Intnchecks intbool — true or false
struct Ratpub struct Rat {
}Public struct `Rat`.
none
new_ratpub fn new_rat(a int, b int) RatConstruct rat.
a intb intRat — a value of this type
(&mut Rat) set_fracpub fn (z &mut Rat) set_frac(a &Int, b &Int) intMethod on `&mut Rat`: set frac. Throws on failure.
z &mut Rata &Intb &Intint — a value of this type
(&Rat) numpub fn (z &Rat) num() IntCall `num` on `&Rat`.
z &RatInt — a value of this type
(&Rat) denompub fn (z &Rat) denom() IntCall `denom` on `&Rat`.
z &RatInt — a value of this type
(&Rat) signpub fn (z &Rat) sign() intMethod on `&Rat`: sign.
z &Ratint — a value of this type
(&mut Rat) addpub fn (z &mut Rat) add(x &Rat, y &Rat)Method on `&mut Rat`: add.
z &mut Ratx &Raty &Rat(&mut Rat) subpub fn (z &mut Rat) sub(x &Rat, y &Rat)Method on `&mut Rat`: subtract.
z &mut Ratx &Raty &Rat(&mut Rat) mulpub fn (z &mut Rat) mul(x &Rat, y &Rat)Method on `&mut Rat`: multiply.
z &mut Ratx &Raty &Rat(&mut Rat) quopub fn (z &mut Rat) quo(x &Rat, y &Rat) intCall `quo` on `&mut Rat`. Throws on failure.
z &mut Ratx &Raty &Ratint — a value of this type
const to_zeropub const to_zero = 0`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`.
none
const to_nearest_evenpub const to_nearest_even = 1Public constant `to_nearest_even`. Value `1`.
none
const to_neg_infpub const to_neg_inf = 2Public constant `to_neg_inf`. Value `2`.
none
const to_pos_infpub const to_pos_inf = 3Public constant `to_pos_inf`. Value `3`.
none
const away_from_zeropub const away_from_zero = 4Public constant `away_from_zero`. Value `4`.
none
struct Floatpub struct Float {
pub prec int
pub neg bool
pub mant Int
pub exp int
pub form int
pub mode int
}Public struct `Float`.
prec intneg boolmant Intexp intform intmode intnew_floatpub fn new_float() FloatConstruct float.
none
Float — a value of this type
(&mut Float) set_precpub fn (z &mut Float) set_prec(p int)Method on `&mut Float`: set prec.
z &mut Floatp int(&Float) precisionpub fn (z &Float) precision() intCall `precision` on `&Float`.
z &Floatint — a value of this type
(&mut Float) set_modepub fn (z &mut Float) set_mode(m int)Method on `&mut Float`: set mode.
z &mut Floatm int(&Float) roundingpub fn (z &Float) rounding() intCall `rounding` on `&Float`.
z &Floatint — a value of this type
(&mut Float) set_infpub fn (z &mut Float) set_inf(neg bool)Method on `&mut Float`: set inf.
z &mut Floatneg bool(&mut Float) set_nanpub fn (z &mut Float) set_nan()Method on `&mut Float`: set nan.
z &mut Float(&Float) is_infpub fn (z &Float) is_inf() boolMethod on `&Float`: whether the value is infinity.
z &Floatbool — true or false
(&Float) is_nanpub fn (z &Float) is_nan() boolMethod on `&Float`: whether the value is NaN.
z &Floatbool — true or false
(&mut Float) setpub fn (z &mut Float) set(x &Float)Call `set` on `&mut Float`.
z &mut Floatx &Float(&mut Float) set_int64pub fn (z &mut Float) set_int64(x int)Method on `&mut Float`: set int64.
z &mut Floatx int(&mut Float) set_intpub fn (z &mut Float) set_int(x &Int)Method on `&mut Float`: set int.
z &mut Floatx &Int(&Float) to_int64pub fn (z &Float) to_int64() intMethod on `&Float`: convert to int64. Throws on failure.
z &Floatint — a value of this type
(&Float) signbitpub fn (z &Float) signbit() boolCall `signbit` on `&Float`.
z &Floatbool — true or false
(&Float) unbiased_exppub fn (z &Float) unbiased_exp() intMethod on `&Float`: unbiased exp.
z &Floatint — a value of this type
(&Float) mantissapub fn (z &Float) mantissa() FloatCall `mantissa` on `&Float`.
z &FloatFloat — a value of this type
(&mut Float) set_mant_exppub fn (z &mut Float) set_mant_exp(mant &Float, exp int)Method on `&mut Float`: set mant exp.
z &mut Floatmant &Floatexp int(&Float) signpub fn (z &Float) sign() intMethod on `&Float`: sign.
z &Floatint — a value of this type
(&Float) cmppub fn (z &Float) cmp(y &Float) intCall `cmp` on `&Float`. Throws on failure.
z &Floaty &Floatint — a value of this type
(&mut Float) addpub fn (z &mut Float) add(x &Float, y &Float)Method on `&mut Float`: add.
z &mut Floatx &Floaty &Float(&mut Float) subpub fn (z &mut Float) sub(x &Float, y &Float)Method on `&mut Float`: subtract.
z &mut Floatx &Floaty &Float(&mut Float) mulpub fn (z &mut Float) mul(x &Float, y &Float)Method on `&mut Float`: multiply.
z &mut Floatx &Floaty &Float(&mut Float) quopub fn (z &mut Float) quo(x &Float, y &Float) intCall `quo` on `&mut Float`. Throws on failure.
z &mut Floatx &Floaty &Floatint — a value of this type
(&Float) textpub fn (z &Float) text() stringMethod on `&Float`: return the current text.
z &Floatstring — result string
(&mut Float) set_stringpub fn (z &mut Float) set_string(s string) intMethod on `&mut Float`: set string. Throws on failure.
z &mut Floats stringint — a value of this type
(&mut Float) set_float64pub fn (z &mut Float) set_float64(x f64) intMethod on `&mut Float`: set float64. Throws on failure.
z &mut Floatx f64int — a value of this type