// Generated by Lisette bindgen
// Source: math/big (Go stdlib)
// Go: 1.25.10
// Lisette: 0.3.0

import "go:fmt"
import "go:math/rand"

/// Accuracy describes the rounding error produced by the most recent
/// operation that generated a [Float] value, relative to the exact value.
pub struct Accuracy(int8)

pub const Above: Accuracy = 1

pub const Below: Accuracy = -1

pub const Exact: Accuracy = 0

/// RoundingMode determines how a [Float] value is rounded to the
/// desired precision. Rounding may change the [Float] value; the
/// rounding error is described by the [Float]'s [Accuracy].
pub struct RoundingMode(byte)

pub const AwayFromZero: RoundingMode = 3

pub const ToNearestAway: RoundingMode = 1

pub const ToNearestEven: RoundingMode = 0

pub const ToNegativeInf: RoundingMode = 4

pub const ToPositiveInf: RoundingMode = 5

pub const ToZero: RoundingMode = 2

/// Jacobi returns the Jacobi symbol (x/y), either +1, -1, or 0.
/// The y argument must be an odd integer.
pub fn Jacobi(x: Ref<Int>, y: Ref<Int>) -> int

/// NewFloat allocates and returns a new [Float] set to x,
/// with precision 53 and rounding mode [ToNearestEven].
/// NewFloat panics with [ErrNaN] if x is a NaN.
pub fn NewFloat(x: float64) -> Ref<Float>

/// NewInt allocates and returns a new [Int] set to x.
pub fn NewInt(x: int64) -> Ref<Int>

/// NewRat creates a new [Rat] with numerator a and denominator b.
pub fn NewRat(a: int64, b: int64) -> Ref<Rat>

/// ParseFloat is like f.Parse(s, base) with f set to the given precision
/// and rounding mode.
pub fn ParseFloat(s: string, base: int, prec: uint, mode: RoundingMode) -> Result<(Ref<Float>, int), error>

/// An ErrNaN panic is raised by a [Float] operation that would lead to
/// a NaN under IEEE 754 rules. An ErrNaN implements the error interface.
pub type ErrNaN

/// A nonzero finite Float represents a multi-precision floating point number
/// 
/// 	sign × mantissa × 2**exponent
/// 
/// with 0.5 <= mantissa < 1.0, and MinExp <= exponent <= MaxExp.
/// A Float may also be zero (+0, -0) or infinite (+Inf, -Inf).
/// All Floats are ordered, and the ordering of two Floats x and y
/// is defined by x.Cmp(y).
/// 
/// Each Float value also has a precision, rounding mode, and accuracy.
/// The precision is the maximum number of mantissa bits available to
/// represent the value. The rounding mode specifies how a result should
/// be rounded to fit into the mantissa bits, and accuracy describes the
/// rounding error with respect to the exact result.
/// 
/// Unless specified otherwise, all operations (including setters) that
/// specify a *Float variable for the result (usually via the receiver
/// with the exception of [Float.MantExp]), round the numeric result according
/// to the precision and rounding mode of the result variable.
/// 
/// If the provided result precision is 0 (see below), it is set to the
/// precision of the argument with the largest precision value before any
/// rounding takes place, and the rounding mode remains unchanged. Thus,
/// uninitialized Floats provided as result arguments will have their
/// precision set to a reasonable value determined by the operands, and
/// their mode is the zero value for RoundingMode (ToNearestEven).
/// 
/// By setting the desired precision to 24 or 53 and using matching rounding
/// mode (typically [ToNearestEven]), Float operations produce the same results
/// as the corresponding float32 or float64 IEEE 754 arithmetic for operands
/// that correspond to normal (i.e., not denormal) float32 or float64 numbers.
/// Exponent underflow and overflow lead to a 0 or an Infinity for different
/// values than IEEE 754 because Float exponents have a much larger range.
/// 
/// The zero (uninitialized) value for a Float is ready to use and represents
/// the number +0.0 exactly, with precision 0 and rounding mode [ToNearestEven].
/// 
/// Operations always take pointer arguments (*Float) rather
/// than Float values, and each unique Float value requires
/// its own unique *Float pointer. To "copy" a Float value,
/// an existing (or newly allocated) Float must be set to
/// a new value using the [Float.Set] method; shallow copies
/// of Floats are not supported and may lead to errors.
pub type Float

/// An Int represents a signed multi-precision integer.
/// The zero value for an Int represents the value 0.
/// 
/// Operations always take pointer arguments (*Int) rather
/// than Int values, and each unique Int value requires
/// its own unique *Int pointer. To "copy" an Int value,
/// an existing (or newly allocated) Int must be set to
/// a new value using the [Int.Set] method; shallow copies
/// of Ints are not supported and may lead to errors.
/// 
/// Note that methods may leak the Int's value through timing side-channels.
/// Because of this and because of the scope and complexity of the
/// implementation, Int is not well-suited to implement cryptographic operations.
/// The standard library avoids exposing non-trivial Int methods to
/// attacker-controlled inputs and the determination of whether a bug in math/big
/// is considered a security vulnerability might depend on the impact on the
/// standard library.
pub type Int

/// A Rat represents a quotient a/b of arbitrary precision.
/// The zero value for a Rat represents the value 0.
/// 
/// Operations always take pointer arguments (*Rat) rather
/// than Rat values, and each unique Rat value requires
/// its own unique *Rat pointer. To "copy" a Rat value,
/// an existing (or newly allocated) Rat must be set to
/// a new value using the [Rat.Set] method; shallow copies
/// of Rats are not supported and may lead to errors.
pub type Rat

/// A Word represents a single digit of a multi-precision unsigned integer.
pub struct Word(uint)

/// MaxBase is the largest number base accepted for string conversions.
pub const MaxBase = 62

/// Exponent and precision limits.
pub const MaxExp = 2147483647

/// Exponent and precision limits.
pub const MaxPrec = 4294967295

/// Exponent and precision limits.
pub const MinExp = -2147483648

impl Accuracy {
  fn String(self) -> string
}

impl ErrNaN {
  fn Error(self) -> string
}

impl Float {
  /// Abs sets z to the (possibly rounded) value |x| (the absolute value of x)
  /// and returns z.
  #[allow(unused_value)]
  fn Abs(self: Ref<Float>, x: Ref<Float>) -> Ref<Float>

  /// Acc returns the accuracy of x produced by the most recent
  /// operation, unless explicitly documented otherwise by that
  /// operation.
  fn Acc(self: Ref<Float>) -> Accuracy

  /// Add sets z to the rounded sum x+y and returns z. If z's precision is 0,
  /// it is changed to the larger of x's or y's precision before the operation.
  /// Rounding is performed according to z's precision and rounding mode; and
  /// z's accuracy reports the result error relative to the exact (not rounded)
  /// result. Add panics with [ErrNaN] if x and y are infinities with opposite
  /// signs. The value of z is undefined in that case.
  #[allow(unused_value)]
  fn Add(self: Ref<Float>, x: Ref<Float>, y: Ref<Float>) -> Ref<Float>

  /// Append appends to buf the string form of the floating-point number x,
  /// as generated by x.Text, and returns the extended buffer.
  fn Append(self: Ref<Float>, mut buf: Slice<byte>, fmt: byte, prec: int) -> Slice<byte>

  /// AppendText implements the [encoding.TextAppender] interface.
  /// Only the [Float] value is marshaled (in full precision), other
  /// attributes such as precision or accuracy are ignored.
  fn AppendText(self: Ref<Float>, mut b: Slice<byte>) -> Result<Slice<byte>, error>

  /// Cmp compares x and y and returns:
  ///   - -1 if x < y;
  ///   - 0 if x == y (incl. -0 == 0, -Inf == -Inf, and +Inf == +Inf);
  ///   - +1 if x > y.
  fn Cmp(self: Ref<Float>, y: Ref<Float>) -> int

  /// Copy sets z to x, with the same precision, rounding mode, and accuracy as x.
  /// Copy returns z. If x and z are identical, Copy is a no-op.
  fn Copy(self: Ref<Float>, x: Ref<Float>) -> Ref<Float>

  /// Float32 returns the float32 value nearest to x. If x is too small to be
  /// represented by a float32 (|x| < [math.SmallestNonzeroFloat32]), the result
  /// is (0, [Below]) or (-0, [Above]), respectively, depending on the sign of x.
  /// If x is too large to be represented by a float32 (|x| > [math.MaxFloat32]),
  /// the result is (+Inf, [Above]) or (-Inf, [Below]), depending on the sign of x.
  fn Float32(self: Ref<Float>) -> (float32, Accuracy)

  /// Float64 returns the float64 value nearest to x. If x is too small to be
  /// represented by a float64 (|x| < [math.SmallestNonzeroFloat64]), the result
  /// is (0, [Below]) or (-0, [Above]), respectively, depending on the sign of x.
  /// If x is too large to be represented by a float64 (|x| > [math.MaxFloat64]),
  /// the result is (+Inf, [Above]) or (-Inf, [Below]), depending on the sign of x.
  fn Float64(self: Ref<Float>) -> (float64, Accuracy)

  /// Format implements [fmt.Formatter]. It accepts all the regular
  /// formats for floating-point numbers ('b', 'e', 'E', 'f', 'F',
  /// 'g', 'G', 'x') as well as 'p' and 'v'. See (*Float).Text for the
  /// interpretation of 'p'. The 'v' format is handled like 'g'.
  /// Format also supports specification of the minimum precision
  /// in digits, the output field width, as well as the format flags
  /// '+' and ' ' for sign control, '0' for space or zero padding,
  /// and '-' for left or right justification. See the fmt package
  /// for details.
  fn Format(self: Ref<Float>, s: fmt.State, format: rune)

  /// GobDecode implements the [encoding/gob.GobDecoder] interface.
  /// The result is rounded per the precision and rounding mode of
  /// z unless z's precision is 0, in which case z is set exactly
  /// to the decoded value.
  fn GobDecode(self: Ref<Float>, buf: Slice<byte>) -> Result<(), error>

  /// GobEncode implements the [encoding/gob.GobEncoder] interface.
  /// The [Float] value and all its attributes (precision,
  /// rounding mode, accuracy) are marshaled.
  fn GobEncode(self: Ref<Float>) -> Result<Slice<byte>, error>

  /// Int returns the result of truncating x towards zero;
  /// or nil if x is an infinity.
  /// The result is [Exact] if x.IsInt(); otherwise it is [Below]
  /// for x > 0, and [Above] for x < 0.
  /// If a non-nil *[Int] argument z is provided, [Int] stores
  /// the result in z instead of allocating a new [Int].
  fn Int(self: Ref<Float>, z: Ref<Int>) -> (Ref<Int>, Accuracy)

  /// Int64 returns the integer resulting from truncating x towards zero.
  /// If [math.MinInt64] <= x <= [math.MaxInt64], the result is [Exact] if x is
  /// an integer, and [Above] (x < 0) or [Below] (x > 0) otherwise.
  /// The result is ([math.MinInt64], [Above]) for x < [math.MinInt64],
  /// and ([math.MaxInt64], [Below]) for x > [math.MaxInt64].
  fn Int64(self: Ref<Float>) -> (int64, Accuracy)

  /// IsInf reports whether x is +Inf or -Inf.
  fn IsInf(self: Ref<Float>) -> bool

  /// IsInt reports whether x is an integer.
  /// ±Inf values are not integers.
  fn IsInt(self: Ref<Float>) -> bool

  /// MantExp breaks x into its mantissa and exponent components
  /// and returns the exponent. If a non-nil mant argument is
  /// provided its value is set to the mantissa of x, with the
  /// same precision and rounding mode as x. The components
  /// satisfy x == mant × 2**exp, with 0.5 <= |mant| < 1.0.
  /// Calling MantExp with a nil argument is an efficient way to
  /// get the exponent of the receiver.
  /// 
  /// Special cases are:
  /// 
  /// 	(  ±0).MantExp(mant) = 0, with mant set to   ±0
  /// 	(±Inf).MantExp(mant) = 0, with mant set to ±Inf
  /// 
  /// x and mant may be the same in which case x is set to its
  /// mantissa value.
  fn MantExp(self: Ref<Float>, mant: Ref<Float>) -> int

  /// MarshalText implements the [encoding.TextMarshaler] interface.
  /// Only the [Float] value is marshaled (in full precision), other
  /// attributes such as precision or accuracy are ignored.
  fn MarshalText(self: Ref<Float>) -> Result<Slice<byte>, error>

  /// MinPrec returns the minimum precision required to represent x exactly
  /// (i.e., the smallest prec before x.SetPrec(prec) would start rounding x).
  /// The result is 0 for |x| == 0 and |x| == Inf.
  fn MinPrec(self: Ref<Float>) -> uint

  /// Mode returns the rounding mode of x.
  fn Mode(self: Ref<Float>) -> RoundingMode

  /// Mul sets z to the rounded product x*y and returns z.
  /// Precision, rounding, and accuracy reporting are as for [Float.Add].
  /// Mul panics with [ErrNaN] if one operand is zero and the other
  /// operand an infinity. The value of z is undefined in that case.
  #[allow(unused_value)]
  fn Mul(self: Ref<Float>, x: Ref<Float>, y: Ref<Float>) -> Ref<Float>

  /// Neg sets z to the (possibly rounded) value of x with its sign negated,
  /// and returns z.
  #[allow(unused_value)]
  fn Neg(self: Ref<Float>, x: Ref<Float>) -> Ref<Float>

  /// Parse parses s which must contain a text representation of a floating-
  /// point number with a mantissa in the given conversion base (the exponent
  /// is always a decimal number), or a string representing an infinite value.
  /// 
  /// For base 0, an underscore character “_” may appear between a base
  /// prefix and an adjacent digit, and between successive digits; such
  /// underscores do not change the value of the number, or the returned
  /// digit count. Incorrect placement of underscores is reported as an
  /// error if there are no other errors. If base != 0, underscores are
  /// not recognized and thus terminate scanning like any other character
  /// that is not a valid radix point or digit.
  /// 
  /// It sets z to the (possibly rounded) value of the corresponding floating-
  /// point value, and returns z, the actual base b, and an error err, if any.
  /// The entire string (not just a prefix) must be consumed for success.
  /// If z's precision is 0, it is changed to 64 before rounding takes effect.
  /// The number must be of the form:
  /// 
  /// 	number    = [ sign ] ( float | "inf" | "Inf" ) .
  /// 	sign      = "+" | "-" .
  /// 	float     = ( mantissa | prefix pmantissa ) [ exponent ] .
  /// 	prefix    = "0" [ "b" | "B" | "o" | "O" | "x" | "X" ] .
  /// 	mantissa  = digits "." [ digits ] | digits | "." digits .
  /// 	pmantissa = [ "_" ] digits "." [ digits ] | [ "_" ] digits | "." digits .
  /// 	exponent  = ( "e" | "E" | "p" | "P" ) [ sign ] digits .
  /// 	digits    = digit { [ "_" ] digit } .
  /// 	digit     = "0" ... "9" | "a" ... "z" | "A" ... "Z" .
  /// 
  /// The base argument must be 0, 2, 8, 10, or 16. Providing an invalid base
  /// argument will lead to a run-time panic.
  /// 
  /// For base 0, the number prefix determines the actual base: A prefix of
  /// “0b” or “0B” selects base 2, “0o” or “0O” selects base 8, and
  /// “0x” or “0X” selects base 16. Otherwise, the actual base is 10 and
  /// no prefix is accepted. The octal prefix "0" is not supported (a leading
  /// "0" is simply considered a "0").
  /// 
  /// A "p" or "P" exponent indicates a base 2 (rather than base 10) exponent;
  /// for instance, "0x1.fffffffffffffp1023" (using base 0) represents the
  /// maximum float64 value. For hexadecimal mantissae, the exponent character
  /// must be one of 'p' or 'P', if present (an "e" or "E" exponent indicator
  /// cannot be distinguished from a mantissa digit).
  /// 
  /// The returned *Float f is nil and the value of z is valid but not
  /// defined if an error is reported.
  fn Parse(self: Ref<Float>, s: string, base: int) -> Result<(Ref<Float>, int), error>

  /// Prec returns the mantissa precision of x in bits.
  /// The result may be 0 for |x| == 0 and |x| == Inf.
  fn Prec(self: Ref<Float>) -> uint

  /// Quo sets z to the rounded quotient x/y and returns z.
  /// Precision, rounding, and accuracy reporting are as for [Float.Add].
  /// Quo panics with [ErrNaN] if both operands are zero or infinities.
  /// The value of z is undefined in that case.
  #[allow(unused_value)]
  fn Quo(self: Ref<Float>, x: Ref<Float>, y: Ref<Float>) -> Ref<Float>

  /// Rat returns the rational number corresponding to x;
  /// or nil if x is an infinity.
  /// The result is [Exact] if x is not an Inf.
  /// If a non-nil *[Rat] argument z is provided, [Rat] stores
  /// the result in z instead of allocating a new [Rat].
  fn Rat(self: Ref<Float>, z: Ref<Rat>) -> (Ref<Rat>, Accuracy)

  /// Scan is a support routine for [fmt.Scanner]; it sets z to the value of
  /// the scanned number. It accepts formats whose verbs are supported by
  /// [fmt.Scan] for floating point values, which are:
  /// 'b' (binary), 'e', 'E', 'f', 'F', 'g' and 'G'.
  /// Scan doesn't handle ±Inf.
  fn Scan(self: Ref<Float>, s: fmt.ScanState, ch: rune) -> Result<(), error>

  /// Set sets z to the (possibly rounded) value of x and returns z.
  /// If z's precision is 0, it is changed to the precision of x
  /// before setting z (and rounding will have no effect).
  /// Rounding is performed according to z's precision and rounding
  /// mode; and z's accuracy reports the result error relative to the
  /// exact (not rounded) result.
  #[allow(unused_value)]
  fn Set(self: Ref<Float>, x: Ref<Float>) -> Ref<Float>

  /// SetFloat64 sets z to the (possibly rounded) value of x and returns z.
  /// If z's precision is 0, it is changed to 53 (and rounding will have
  /// no effect). SetFloat64 panics with [ErrNaN] if x is a NaN.
  #[allow(unused_value)]
  fn SetFloat64(self: Ref<Float>, x: float64) -> Ref<Float>

  /// SetInf sets z to the infinite Float -Inf if signbit is
  /// set, or +Inf if signbit is not set, and returns z. The
  /// precision of z is unchanged and the result is always
  /// [Exact].
  #[allow(unused_value)]
  fn SetInf(self: Ref<Float>, signbit: bool) -> Ref<Float>

  /// SetInt sets z to the (possibly rounded) value of x and returns z.
  /// If z's precision is 0, it is changed to the larger of x.BitLen()
  /// or 64 (and rounding will have no effect).
  #[allow(unused_value)]
  fn SetInt(self: Ref<Float>, x: Ref<Int>) -> Ref<Float>

  /// SetInt64 sets z to the (possibly rounded) value of x and returns z.
  /// If z's precision is 0, it is changed to 64 (and rounding will have
  /// no effect).
  #[allow(unused_value)]
  fn SetInt64(self: Ref<Float>, x: int64) -> Ref<Float>

  /// SetMantExp sets z to mant × 2**exp and returns z.
  /// The result z has the same precision and rounding mode
  /// as mant. SetMantExp is an inverse of [Float.MantExp] but does
  /// not require 0.5 <= |mant| < 1.0. Specifically, for a
  /// given x of type *[Float], SetMantExp relates to [Float.MantExp]
  /// as follows:
  /// 
  /// 	mant := new(Float)
  /// 	new(Float).SetMantExp(mant, x.MantExp(mant)).Cmp(x) == 0
  /// 
  /// Special cases are:
  /// 
  /// 	z.SetMantExp(  ±0, exp) =   ±0
  /// 	z.SetMantExp(±Inf, exp) = ±Inf
  /// 
  /// z and mant may be the same in which case z's exponent
  /// is set to exp.
  #[allow(unused_value)]
  fn SetMantExp(self: Ref<Float>, mant: Ref<Float>, exp: int) -> Ref<Float>

  /// SetMode sets z's rounding mode to mode and returns an exact z.
  /// z remains unchanged otherwise.
  /// z.SetMode(z.Mode()) is a cheap way to set z's accuracy to [Exact].
  #[allow(unused_value)]
  fn SetMode(self: Ref<Float>, mode: RoundingMode) -> Ref<Float>

  /// SetPrec sets z's precision to prec and returns the (possibly) rounded
  /// value of z. Rounding occurs according to z's rounding mode if the mantissa
  /// cannot be represented in prec bits without loss of precision.
  /// SetPrec(0) maps all finite values to ±0; infinite values remain unchanged.
  /// If prec > [MaxPrec], it is set to [MaxPrec].
  #[allow(unused_value)]
  fn SetPrec(self: Ref<Float>, prec: uint) -> Ref<Float>

  /// SetRat sets z to the (possibly rounded) value of x and returns z.
  /// If z's precision is 0, it is changed to the largest of a.BitLen(),
  /// b.BitLen(), or 64; with x = a/b.
  #[allow(unused_value)]
  fn SetRat(self: Ref<Float>, x: Ref<Rat>) -> Ref<Float>

  /// SetString sets z to the value of s and returns z and a boolean indicating
  /// success. s must be a floating-point number of the same format as accepted
  /// by [Float.Parse], with base argument 0. The entire string (not just a prefix) must
  /// be valid for success. If the operation failed, the value of z is undefined
  /// but the returned value is nil.
  #[go(comma_ok)]
  fn SetString(self: Ref<Float>, s: string) -> Option<Ref<Float>>

  /// SetUint64 sets z to the (possibly rounded) value of x and returns z.
  /// If z's precision is 0, it is changed to 64 (and rounding will have
  /// no effect).
  #[allow(unused_value)]
  fn SetUint64(self: Ref<Float>, x: uint64) -> Ref<Float>

  /// Sign returns:
  ///   - -1 if x < 0;
  ///   - 0 if x is ±0;
  ///   - +1 if x > 0.
  fn Sign(self: Ref<Float>) -> int

  /// Signbit reports whether x is negative or negative zero.
  fn Signbit(self: Ref<Float>) -> bool

  /// Sqrt sets z to the rounded square root of x, and returns it.
  /// 
  /// If z's precision is 0, it is changed to x's precision before the
  /// operation. Rounding is performed according to z's precision and
  /// rounding mode, but z's accuracy is not computed. Specifically, the
  /// result of z.Acc() is undefined.
  /// 
  /// The function panics if z < 0. The value of z is undefined in that
  /// case.
  #[allow(unused_value)]
  fn Sqrt(self: Ref<Float>, x: Ref<Float>) -> Ref<Float>

  /// String formats x like x.Text('g', 10).
  /// (String must be called explicitly, [Float.Format] does not support %s verb.)
  fn String(self: Ref<Float>) -> string

  /// Sub sets z to the rounded difference x-y and returns z.
  /// Precision, rounding, and accuracy reporting are as for [Float.Add].
  /// Sub panics with [ErrNaN] if x and y are infinities with equal
  /// signs. The value of z is undefined in that case.
  #[allow(unused_value)]
  fn Sub(self: Ref<Float>, x: Ref<Float>, y: Ref<Float>) -> Ref<Float>

  /// Text converts the floating-point number x to a string according
  /// to the given format and precision prec. The format is one of:
  /// 
  /// 	'e'	-d.dddde±dd, decimal exponent, at least two (possibly 0) exponent digits
  /// 	'E'	-d.ddddE±dd, decimal exponent, at least two (possibly 0) exponent digits
  /// 	'f'	-ddddd.dddd, no exponent
  /// 	'g'	like 'e' for large exponents, like 'f' otherwise
  /// 	'G'	like 'E' for large exponents, like 'f' otherwise
  /// 	'x'	-0xd.dddddp±dd, hexadecimal mantissa, decimal power of two exponent
  /// 	'p'	-0x.dddp±dd, hexadecimal mantissa, decimal power of two exponent (non-standard)
  /// 	'b'	-ddddddp±dd, decimal mantissa, decimal power of two exponent (non-standard)
  /// 
  /// For the power-of-two exponent formats, the mantissa is printed in normalized form:
  /// 
  /// 	'x'	hexadecimal mantissa in [1, 2), or 0
  /// 	'p'	hexadecimal mantissa in [½, 1), or 0
  /// 	'b'	decimal integer mantissa using x.Prec() bits, or 0
  /// 
  /// Note that the 'x' form is the one used by most other languages and libraries.
  /// 
  /// If format is a different character, Text returns a "%" followed by the
  /// unrecognized format character.
  /// 
  /// The precision prec controls the number of digits (excluding the exponent)
  /// printed by the 'e', 'E', 'f', 'g', 'G', and 'x' formats.
  /// For 'e', 'E', 'f', and 'x', it is the number of digits after the decimal point.
  /// For 'g' and 'G' it is the total number of digits. A negative precision selects
  /// the smallest number of decimal digits necessary to identify the value x uniquely
  /// using x.Prec() mantissa bits.
  /// The prec value is ignored for the 'b' and 'p' formats.
  fn Text(self: Ref<Float>, format: byte, prec: int) -> string

  /// Uint64 returns the unsigned integer resulting from truncating x
  /// towards zero. If 0 <= x <= [math.MaxUint64], the result is [Exact]
  /// if x is an integer and [Below] otherwise.
  /// The result is (0, [Above]) for x < 0, and ([math.MaxUint64], [Below])
  /// for x > [math.MaxUint64].
  fn Uint64(self: Ref<Float>) -> (uint64, Accuracy)

  /// UnmarshalText implements the [encoding.TextUnmarshaler] interface.
  /// The result is rounded per the precision and rounding mode of z.
  /// If z's precision is 0, it is changed to 64 before rounding takes
  /// effect.
  fn UnmarshalText(self: Ref<Float>, text: Slice<byte>) -> Result<(), error>
}

impl Int {
  /// Abs sets z to |x| (the absolute value of x) and returns z.
  #[allow(unused_value)]
  fn Abs(self: Ref<Int>, x: Ref<Int>) -> Ref<Int>

  /// Add sets z to the sum x+y and returns z.
  #[allow(unused_value)]
  fn Add(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>

  /// And sets z = x & y and returns z.
  #[allow(unused_value)]
  fn And(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>

  /// AndNot sets z = x &^ y and returns z.
  #[allow(unused_value)]
  fn AndNot(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>

  /// Append appends the string representation of x, as generated by
  /// x.Text(base), to buf and returns the extended buffer.
  fn Append(self: Ref<Int>, mut buf: Slice<byte>, base: int) -> Slice<byte>

  /// AppendText implements the [encoding.TextAppender] interface.
  fn AppendText(self: Ref<Int>, mut b: Slice<byte>) -> Result<Slice<byte>, error>

  /// Binomial sets z to the binomial coefficient C(n, k) and returns z.
  #[allow(unused_value)]
  fn Binomial(self: Ref<Int>, n: int64, k: int64) -> Ref<Int>

  /// Bit returns the value of the i'th bit of x. That is, it
  /// returns (x>>i)&1. The bit index i must be >= 0.
  fn Bit(self: Ref<Int>, i: int) -> uint

  /// BitLen returns the length of the absolute value of x in bits.
  /// The bit length of 0 is 0.
  fn BitLen(self: Ref<Int>) -> int

  /// Bits provides raw (unchecked but fast) access to x by returning its
  /// absolute value as a little-endian [Word] slice. The result and x share
  /// the same underlying array.
  /// Bits is intended to support implementation of missing low-level [Int]
  /// functionality outside this package; it should be avoided otherwise.
  fn Bits(self: Ref<Int>) -> Slice<Word>

  /// Bytes returns the absolute value of x as a big-endian byte slice.
  /// 
  /// To use a fixed length slice, or a preallocated one, use [Int.FillBytes].
  fn Bytes(self: Ref<Int>) -> Slice<byte>

  /// Cmp compares x and y and returns:
  ///   - -1 if x < y;
  ///   - 0 if x == y;
  ///   - +1 if x > y.
  fn Cmp(self: Ref<Int>, y: Ref<Int>) -> int

  /// CmpAbs compares the absolute values of x and y and returns:
  ///   - -1 if |x| < |y|;
  ///   - 0 if |x| == |y|;
  ///   - +1 if |x| > |y|.
  fn CmpAbs(self: Ref<Int>, y: Ref<Int>) -> int

  /// Div sets z to the quotient x/y for y != 0 and returns z.
  /// If y == 0, a division-by-zero run-time panic occurs.
  /// Div implements Euclidean division (unlike Go); see [Int.DivMod] for more details.
  #[allow(unused_value)]
  fn Div(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>

  /// DivMod sets z to the quotient x div y and m to the modulus x mod y
  /// and returns the pair (z, m) for y != 0.
  /// If y == 0, a division-by-zero run-time panic occurs.
  /// 
  /// DivMod implements Euclidean division and modulus (unlike Go):
  /// 
  /// 	q = x div y  such that
  /// 	m = x - y*q  with 0 <= m < |y|
  /// 
  /// (See Raymond T. Boute, “The Euclidean definition of the functions
  /// div and mod”. ACM Transactions on Programming Languages and
  /// Systems (TOPLAS), 14(2):127-144, New York, NY, USA, 4/1992.
  /// ACM press.)
  /// See [Int.QuoRem] for T-division and modulus (like Go).
  fn DivMod(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>, m: Ref<Int>) -> (Ref<Int>, Ref<Int>)

  /// Exp sets z = x**y mod |m| (i.e. the sign of m is ignored), and returns z.
  /// If m == nil or m == 0, z = x**y unless y <= 0 then z = 1. If m != 0, y < 0,
  /// and x and m are not relatively prime, z is unchanged and nil is returned.
  /// 
  /// Modular exponentiation of inputs of a particular size is not a
  /// cryptographically constant-time operation.
  #[allow(unused_value)]
  fn Exp(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>, m: Ref<Int>) -> Option<Ref<Int>>

  /// FillBytes sets buf to the absolute value of x, storing it as a zero-extended
  /// big-endian byte slice, and returns buf.
  /// 
  /// If the absolute value of x doesn't fit in buf, FillBytes will panic.
  fn FillBytes(self: Ref<Int>, mut buf: Slice<byte>) -> Slice<byte>

  /// Float64 returns the float64 value nearest x,
  /// and an indication of any rounding that occurred.
  fn Float64(self: Ref<Int>) -> (float64, Accuracy)

  /// Format implements [fmt.Formatter]. It accepts the formats
  /// 'b' (binary), 'o' (octal with 0 prefix), 'O' (octal with 0o prefix),
  /// 'd' (decimal), 'x' (lowercase hexadecimal), and
  /// 'X' (uppercase hexadecimal).
  /// Also supported are the full suite of package fmt's format
  /// flags for integral types, including '+' and ' ' for sign
  /// control, '#' for leading zero in octal and for hexadecimal,
  /// a leading "0x" or "0X" for "%#x" and "%#X" respectively,
  /// specification of minimum digits precision, output field
  /// width, space or zero padding, and '-' for left or right
  /// justification.
  fn Format(self: Ref<Int>, s: fmt.State, ch: rune)

  /// GCD sets z to the greatest common divisor of a and b and returns z.
  /// If x or y are not nil, GCD sets their value such that z = a*x + b*y.
  /// 
  /// a and b may be positive, zero or negative. (Before Go 1.14 both had
  /// to be > 0.) Regardless of the signs of a and b, z is always >= 0.
  /// 
  /// If a == b == 0, GCD sets z = x = y = 0.
  /// 
  /// If a == 0 and b != 0, GCD sets z = |b|, x = 0, y = sign(b) * 1.
  /// 
  /// If a != 0 and b == 0, GCD sets z = |a|, x = sign(a) * 1, y = 0.
  #[allow(unused_value)]
  fn GCD(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>, a: Ref<Int>, b: Ref<Int>) -> Ref<Int>

  /// GobDecode implements the [encoding/gob.GobDecoder] interface.
  fn GobDecode(self: Ref<Int>, buf: Slice<byte>) -> Result<(), error>

  /// GobEncode implements the [encoding/gob.GobEncoder] interface.
  fn GobEncode(self: Ref<Int>) -> Result<Slice<byte>, error>

  /// Int64 returns the int64 representation of x.
  /// If x cannot be represented in an int64, the result is undefined.
  fn Int64(self: Ref<Int>) -> int64

  /// IsInt64 reports whether x can be represented as an int64.
  fn IsInt64(self: Ref<Int>) -> bool

  /// IsUint64 reports whether x can be represented as a uint64.
  fn IsUint64(self: Ref<Int>) -> bool

  /// Lsh sets z = x << n and returns z.
  #[allow(unused_value)]
  fn Lsh(self: Ref<Int>, x: Ref<Int>, n: uint) -> Ref<Int>

  /// MarshalJSON implements the [encoding/json.Marshaler] interface.
  fn MarshalJSON(self: Ref<Int>) -> Result<Slice<byte>, error>

  /// MarshalText implements the [encoding.TextMarshaler] interface.
  fn MarshalText(self: Ref<Int>) -> Result<Slice<byte>, error>

  /// Mod sets z to the modulus x%y for y != 0 and returns z.
  /// If y == 0, a division-by-zero run-time panic occurs.
  /// Mod implements Euclidean modulus (unlike Go); see [Int.DivMod] for more details.
  #[allow(unused_value)]
  fn Mod(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>

  /// ModInverse sets z to the multiplicative inverse of g in the ring ℤ/nℤ
  /// and returns z. If g and n are not relatively prime, g has no multiplicative
  /// inverse in the ring ℤ/nℤ.  In this case, z is unchanged and the return value
  /// is nil. If n == 0, a division-by-zero run-time panic occurs.
  fn ModInverse(self: Ref<Int>, g: Ref<Int>, n: Ref<Int>) -> Option<Ref<Int>>

  /// ModSqrt sets z to a square root of x mod p if such a square root exists, and
  /// returns z. The modulus p must be an odd prime. If x is not a square mod p,
  /// ModSqrt leaves z unchanged and returns nil. This function panics if p is
  /// not an odd integer, its behavior is undefined if p is odd but not prime.
  fn ModSqrt(self: Ref<Int>, x: Ref<Int>, p: Ref<Int>) -> Option<Ref<Int>>

  /// Mul sets z to the product x*y and returns z.
  #[allow(unused_value)]
  fn Mul(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>

  /// MulRange sets z to the product of all integers
  /// in the range [a, b] inclusively and returns z.
  /// If a > b (empty range), the result is 1.
  #[allow(unused_value)]
  fn MulRange(self: Ref<Int>, a: int64, b: int64) -> Ref<Int>

  /// Neg sets z to -x and returns z.
  #[allow(unused_value)]
  fn Neg(self: Ref<Int>, x: Ref<Int>) -> Ref<Int>

  /// Not sets z = ^x and returns z.
  #[allow(unused_value)]
  fn Not(self: Ref<Int>, x: Ref<Int>) -> Ref<Int>

  /// Or sets z = x | y and returns z.
  #[allow(unused_value)]
  fn Or(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>

  /// ProbablyPrime reports whether x is probably prime,
  /// applying the Miller-Rabin test with n pseudorandomly chosen bases
  /// as well as a Baillie-PSW test.
  /// 
  /// If x is prime, ProbablyPrime returns true.
  /// If x is chosen randomly and not prime, ProbablyPrime probably returns false.
  /// The probability of returning true for a randomly chosen non-prime is at most ¼ⁿ.
  /// 
  /// ProbablyPrime is 100% accurate for inputs less than 2⁶⁴.
  /// See Menezes et al., Handbook of Applied Cryptography, 1997, pp. 145-149,
  /// and FIPS 186-4 Appendix F for further discussion of the error probabilities.
  /// 
  /// ProbablyPrime is not suitable for judging primes that an adversary may
  /// have crafted to fool the test.
  /// 
  /// As of Go 1.8, ProbablyPrime(0) is allowed and applies only a Baillie-PSW test.
  /// Before Go 1.8, ProbablyPrime applied only the Miller-Rabin tests, and ProbablyPrime(0) panicked.
  fn ProbablyPrime(self: Ref<Int>, n: int) -> bool

  /// Quo sets z to the quotient x/y for y != 0 and returns z.
  /// If y == 0, a division-by-zero run-time panic occurs.
  /// Quo implements truncated division (like Go); see [Int.QuoRem] for more details.
  #[allow(unused_value)]
  fn Quo(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>

  /// QuoRem sets z to the quotient x/y and r to the remainder x%y
  /// and returns the pair (z, r) for y != 0.
  /// If y == 0, a division-by-zero run-time panic occurs.
  /// 
  /// QuoRem implements T-division and modulus (like Go):
  /// 
  /// 	q = x/y      with the result truncated to zero
  /// 	r = x - y*q
  /// 
  /// (See Daan Leijen, “Division and Modulus for Computer Scientists”.)
  /// See [Int.DivMod] for Euclidean division and modulus (unlike Go).
  fn QuoRem(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>, r: Ref<Int>) -> (Ref<Int>, Ref<Int>)

  /// Rand sets z to a pseudo-random number in [0, n) and returns z.
  /// 
  /// As this uses the [math/rand] package, it must not be used for
  /// security-sensitive work. Use [crypto/rand.Int] instead.
  #[allow(unused_value)]
  fn Rand(self: Ref<Int>, rnd: Ref<rand.Rand>, n: Ref<Int>) -> Ref<Int>

  /// Rem sets z to the remainder x%y for y != 0 and returns z.
  /// If y == 0, a division-by-zero run-time panic occurs.
  /// Rem implements truncated modulus (like Go); see [Int.QuoRem] for more details.
  #[allow(unused_value)]
  fn Rem(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>

  /// Rsh sets z = x >> n and returns z.
  #[allow(unused_value)]
  fn Rsh(self: Ref<Int>, x: Ref<Int>, n: uint) -> Ref<Int>

  /// Scan is a support routine for [fmt.Scanner]; it sets z to the value of
  /// the scanned number. It accepts the formats 'b' (binary), 'o' (octal),
  /// 'd' (decimal), 'x' (lowercase hexadecimal), and 'X' (uppercase hexadecimal).
  fn Scan(self: Ref<Int>, s: fmt.ScanState, ch: rune) -> Result<(), error>

  /// Set sets z to x and returns z.
  #[allow(unused_value)]
  fn Set(self: Ref<Int>, x: Ref<Int>) -> Ref<Int>

  /// SetBit sets z to x, with x's i'th bit set to b (0 or 1).
  /// That is,
  ///   - if b is 1, SetBit sets z = x | (1 << i);
  ///   - if b is 0, SetBit sets z = x &^ (1 << i);
  ///   - if b is not 0 or 1, SetBit will panic.
  #[allow(unused_value)]
  fn SetBit(self: Ref<Int>, x: Ref<Int>, i: int, b: uint) -> Ref<Int>

  /// SetBits provides raw (unchecked but fast) access to z by setting its
  /// value to abs, interpreted as a little-endian [Word] slice, and returning
  /// z. The result and abs share the same underlying array.
  /// SetBits is intended to support implementation of missing low-level [Int]
  /// functionality outside this package; it should be avoided otherwise.
  #[allow(unused_value)]
  fn SetBits(self: Ref<Int>, abs: Slice<Word>) -> Ref<Int>

  /// SetBytes interprets buf as the bytes of a big-endian unsigned
  /// integer, sets z to that value, and returns z.
  #[allow(unused_value)]
  fn SetBytes(self: Ref<Int>, buf: Slice<byte>) -> Ref<Int>

  /// SetInt64 sets z to x and returns z.
  #[allow(unused_value)]
  fn SetInt64(self: Ref<Int>, x: int64) -> Ref<Int>

  /// SetString sets z to the value of s, interpreted in the given base,
  /// and returns z and a boolean indicating success. The entire string
  /// (not just a prefix) must be valid for success. If SetString fails,
  /// the value of z is undefined but the returned value is nil.
  /// 
  /// The base argument must be 0 or a value between 2 and [MaxBase].
  /// For base 0, the number prefix determines the actual base: A prefix of
  /// “0b” or “0B” selects base 2, “0”, “0o” or “0O” selects base 8,
  /// and “0x” or “0X” selects base 16. Otherwise, the selected base is 10
  /// and no prefix is accepted.
  /// 
  /// For bases <= 36, lower and upper case letters are considered the same:
  /// The letters 'a' to 'z' and 'A' to 'Z' represent digit values 10 to 35.
  /// For bases > 36, the upper case letters 'A' to 'Z' represent the digit
  /// values 36 to 61.
  /// 
  /// For base 0, an underscore character “_” may appear between a base
  /// prefix and an adjacent digit, and between successive digits; such
  /// underscores do not change the value of the number.
  /// Incorrect placement of underscores is reported as an error if there
  /// are no other errors. If base != 0, underscores are not recognized
  /// and act like any other character that is not a valid digit.
  #[go(comma_ok)]
  fn SetString(self: Ref<Int>, s: string, base: int) -> Option<Ref<Int>>

  /// SetUint64 sets z to x and returns z.
  #[allow(unused_value)]
  fn SetUint64(self: Ref<Int>, x: uint64) -> Ref<Int>

  /// Sign returns:
  ///   - -1 if x < 0;
  ///   - 0 if x == 0;
  ///   - +1 if x > 0.
  fn Sign(self: Ref<Int>) -> int

  /// Sqrt sets z to ⌊√x⌋, the largest integer such that z² ≤ x, and returns z.
  /// It panics if x is negative.
  #[allow(unused_value)]
  fn Sqrt(self: Ref<Int>, x: Ref<Int>) -> Ref<Int>

  /// String returns the decimal representation of x as generated by
  /// x.Text(10).
  fn String(self: Ref<Int>) -> string

  /// Sub sets z to the difference x-y and returns z.
  #[allow(unused_value)]
  fn Sub(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>

  /// Text returns the string representation of x in the given base.
  /// Base must be between 2 and 62, inclusive. The result uses the
  /// lower-case letters 'a' to 'z' for digit values 10 to 35, and
  /// the upper-case letters 'A' to 'Z' for digit values 36 to 61.
  /// No prefix (such as "0x") is added to the string. If x is a nil
  /// pointer it returns "<nil>".
  fn Text(self: Ref<Int>, base: int) -> string

  /// TrailingZeroBits returns the number of consecutive least significant zero
  /// bits of |x|.
  fn TrailingZeroBits(self: Ref<Int>) -> uint

  /// Uint64 returns the uint64 representation of x.
  /// If x cannot be represented in a uint64, the result is undefined.
  fn Uint64(self: Ref<Int>) -> uint64

  /// UnmarshalJSON implements the [encoding/json.Unmarshaler] interface.
  fn UnmarshalJSON(self: Ref<Int>, text: Slice<byte>) -> Result<(), error>

  /// UnmarshalText implements the [encoding.TextUnmarshaler] interface.
  fn UnmarshalText(self: Ref<Int>, text: Slice<byte>) -> Result<(), error>

  /// Xor sets z = x ^ y and returns z.
  #[allow(unused_value)]
  fn Xor(self: Ref<Int>, x: Ref<Int>, y: Ref<Int>) -> Ref<Int>
}

impl Rat {
  /// Abs sets z to |x| (the absolute value of x) and returns z.
  #[allow(unused_value)]
  fn Abs(self: Ref<Rat>, x: Ref<Rat>) -> Ref<Rat>

  /// Add sets z to the sum x+y and returns z.
  #[allow(unused_value)]
  fn Add(self: Ref<Rat>, x: Ref<Rat>, y: Ref<Rat>) -> Ref<Rat>

  /// AppendText implements the [encoding.TextAppender] interface.
  fn AppendText(self: Ref<Rat>, mut b: Slice<byte>) -> Result<Slice<byte>, error>

  /// Cmp compares x and y and returns:
  ///   - -1 if x < y;
  ///   - 0 if x == y;
  ///   - +1 if x > y.
  fn Cmp(self: Ref<Rat>, y: Ref<Rat>) -> int

  /// Denom returns the denominator of x; it is always > 0.
  /// The result is a reference to x's denominator, unless
  /// x is an uninitialized (zero value) [Rat], in which case
  /// the result is a new [Int] of value 1. (To initialize x,
  /// any operation that sets x will do, including x.Set(x).)
  /// If the result is a reference to x's denominator it
  /// may change if a new value is assigned to x, and vice versa.
  fn Denom(self: Ref<Rat>) -> Ref<Int>

  /// Float32 returns the nearest float32 value for x and a bool indicating
  /// whether f represents x exactly. If the magnitude of x is too large to
  /// be represented by a float32, f is an infinity and exact is false.
  /// The sign of f always matches the sign of x, even if f == 0.
  fn Float32(self: Ref<Rat>) -> (float32, bool)

  /// Float64 returns the nearest float64 value for x and a bool indicating
  /// whether f represents x exactly. If the magnitude of x is too large to
  /// be represented by a float64, f is an infinity and exact is false.
  /// The sign of f always matches the sign of x, even if f == 0.
  fn Float64(self: Ref<Rat>) -> (float64, bool)

  /// FloatPrec returns the number n of non-repeating digits immediately
  /// following the decimal point of the decimal representation of x.
  /// The boolean result indicates whether a decimal representation of x
  /// with that many fractional digits is exact or rounded.
  /// 
  /// Examples:
  /// 
  /// 	x      n    exact    decimal representation n fractional digits
  /// 	0      0    true     0
  /// 	1      0    true     1
  /// 	1/2    1    true     0.5
  /// 	1/3    0    false    0       (0.333... rounded)
  /// 	1/4    2    true     0.25
  /// 	1/6    1    false    0.2     (0.166... rounded)
  fn FloatPrec(self: Ref<Rat>) -> (int, bool)

  /// FloatString returns a string representation of x in decimal form with prec
  /// digits of precision after the radix point. The last digit is rounded to
  /// nearest, with halves rounded away from zero.
  fn FloatString(self: Ref<Rat>, prec: int) -> string

  /// GobDecode implements the [encoding/gob.GobDecoder] interface.
  fn GobDecode(self: Ref<Rat>, buf: Slice<byte>) -> Result<(), error>

  /// GobEncode implements the [encoding/gob.GobEncoder] interface.
  fn GobEncode(self: Ref<Rat>) -> Result<Slice<byte>, error>

  /// Inv sets z to 1/x and returns z.
  /// If x == 0, Inv panics.
  #[allow(unused_value)]
  fn Inv(self: Ref<Rat>, x: Ref<Rat>) -> Ref<Rat>

  /// IsInt reports whether the denominator of x is 1.
  fn IsInt(self: Ref<Rat>) -> bool

  /// MarshalText implements the [encoding.TextMarshaler] interface.
  fn MarshalText(self: Ref<Rat>) -> Result<Slice<byte>, error>

  /// Mul sets z to the product x*y and returns z.
  #[allow(unused_value)]
  fn Mul(self: Ref<Rat>, x: Ref<Rat>, y: Ref<Rat>) -> Ref<Rat>

  /// Neg sets z to -x and returns z.
  #[allow(unused_value)]
  fn Neg(self: Ref<Rat>, x: Ref<Rat>) -> Ref<Rat>

  /// Num returns the numerator of x; it may be <= 0.
  /// The result is a reference to x's numerator; it
  /// may change if a new value is assigned to x, and vice versa.
  /// The sign of the numerator corresponds to the sign of x.
  fn Num(self: Ref<Rat>) -> Ref<Int>

  /// Quo sets z to the quotient x/y and returns z.
  /// If y == 0, Quo panics.
  #[allow(unused_value)]
  fn Quo(self: Ref<Rat>, x: Ref<Rat>, y: Ref<Rat>) -> Ref<Rat>

  /// RatString returns a string representation of x in the form "a/b" if b != 1,
  /// and in the form "a" if b == 1.
  fn RatString(self: Ref<Rat>) -> string

  /// Scan is a support routine for fmt.Scanner. It accepts the formats
  /// 'e', 'E', 'f', 'F', 'g', 'G', and 'v'. All formats are equivalent.
  fn Scan(self: Ref<Rat>, s: fmt.ScanState, ch: rune) -> Result<(), error>

  /// Set sets z to x (by making a copy of x) and returns z.
  #[allow(unused_value)]
  fn Set(self: Ref<Rat>, x: Ref<Rat>) -> Ref<Rat>

  /// SetFloat64 sets z to exactly f and returns z.
  /// If f is not finite, SetFloat returns nil.
  fn SetFloat64(self: Ref<Rat>, f: float64) -> Option<Ref<Rat>>

  /// SetFrac sets z to a/b and returns z.
  /// If b == 0, SetFrac panics.
  #[allow(unused_value)]
  fn SetFrac(self: Ref<Rat>, a: Ref<Int>, b: Ref<Int>) -> Ref<Rat>

  /// SetFrac64 sets z to a/b and returns z.
  /// If b == 0, SetFrac64 panics.
  #[allow(unused_value)]
  fn SetFrac64(self: Ref<Rat>, a: int64, b: int64) -> Ref<Rat>

  /// SetInt sets z to x (by making a copy of x) and returns z.
  #[allow(unused_value)]
  fn SetInt(self: Ref<Rat>, x: Ref<Int>) -> Ref<Rat>

  /// SetInt64 sets z to x and returns z.
  #[allow(unused_value)]
  fn SetInt64(self: Ref<Rat>, x: int64) -> Ref<Rat>

  /// SetString sets z to the value of s and returns z and a boolean indicating
  /// success. s can be given as a (possibly signed) fraction "a/b", or as a
  /// floating-point number optionally followed by an exponent.
  /// If a fraction is provided, both the dividend and the divisor may be a
  /// decimal integer or independently use a prefix of “0b”, “0” or “0o”,
  /// or “0x” (or their upper-case variants) to denote a binary, octal, or
  /// hexadecimal integer, respectively. The divisor may not be signed.
  /// If a floating-point number is provided, it may be in decimal form or
  /// use any of the same prefixes as above but for “0” to denote a non-decimal
  /// mantissa. A leading “0” is considered a decimal leading 0; it does not
  /// indicate octal representation in this case.
  /// An optional base-10 “e” or base-2 “p” (or their upper-case variants)
  /// exponent may be provided as well, except for hexadecimal floats which
  /// only accept an (optional) “p” exponent (because an “e” or “E” cannot
  /// be distinguished from a mantissa digit). If the exponent's absolute value
  /// is too large, the operation may fail.
  /// The entire string, not just a prefix, must be valid for success. If the
  /// operation failed, the value of z is undefined but the returned value is nil.
  #[go(comma_ok)]
  fn SetString(self: Ref<Rat>, s: string) -> Option<Ref<Rat>>

  /// SetUint64 sets z to x and returns z.
  #[allow(unused_value)]
  fn SetUint64(self: Ref<Rat>, x: uint64) -> Ref<Rat>

  /// Sign returns:
  ///   - -1 if x < 0;
  ///   - 0 if x == 0;
  ///   - +1 if x > 0.
  fn Sign(self: Ref<Rat>) -> int

  /// String returns a string representation of x in the form "a/b" (even if b == 1).
  fn String(self: Ref<Rat>) -> string

  /// Sub sets z to the difference x-y and returns z.
  #[allow(unused_value)]
  fn Sub(self: Ref<Rat>, x: Ref<Rat>, y: Ref<Rat>) -> Ref<Rat>

  /// UnmarshalText implements the [encoding.TextUnmarshaler] interface.
  fn UnmarshalText(self: Ref<Rat>, text: Slice<byte>) -> Result<(), error>
}

impl RoundingMode {
  fn String(self) -> string
}
