GMP.Q
Defined in gmp-fix@0.6.0
Provides multiple-precision rational number type MPQ and related functions.
Repository: https://github.com/tttmmmyyyy/fixlang-gmp
Values
namespace GMP.Q
c_SiZE_OF_MPQ
Type: Std::FFI::CInt
Size of __mpq_struct.
namespace GMP.Q::MPQ
abs
Type: GMP.Q::MPQ -> GMP.Q::MPQ
Returns the absolute value of the MPQ value.
Parameters
num: TheMPQvalue to be converted to its absolute value
cmp
Type: GMP.Q::MPQ -> GMP.Q::MPQ -> Std::I64
Compares two MPQ values.
Returns
- a negative if
lhsis less thanrhs, - zero if they are equal,
- a positive if
lhsis greater thanrhs.
Parameters
lhs: The left-hand sideMPQvalue.rhs: The right-hand sideMPQvalue.
cmp_z
Type: GMP.Q::MPQ -> GMP.Z::MPZ -> Std::I64
Compares an MPQ value with an MPZ value.
Returns
- a negative if
lhsis less thanrhs, - zero if they are equal,
- a positive if
lhsis greater thanrhs.
Parameters
lhs: The left-hand sideMPQvalue.rhs: The right-hand sideMPZvalue.
div_2exp
Type: Std::U64 -> GMP.Q::MPQ -> GMP.Q::MPQ
Divides the MPQ value by 2^exp.
Parameters
exp: The exponent of 2.num: TheMPQvalue to be divided.
equal
Type: GMP.Q::MPQ -> GMP.Q::MPQ -> Std::Bool
Checks if two MPQ values are equal.
Parameters
lhs: The left-hand sideMPQvalue.rhs: The right-hand sideMPQvalue.
get_d
Type: GMP.Q::MPQ -> Std::F64
Converts a MPZ value to an F64 value.
For details, see the document of mpz_get_d in GMP.
Parameters
num: TheMPQvalue to be converted to F64.
get_den
Type: GMP.Q::MPQ -> GMP.Z::MPZ
Gets the denominator of the MPQ value.
Parameters
num: TheMPQvalue from which to get the denominator.
get_num
Type: GMP.Q::MPQ -> GMP.Z::MPZ
Gets the numerator of the MPQ value.
Parameters
num: TheMPQvalue from which to get the numerator.
get_str
Type: Std::I64 -> GMP.Q::MPQ -> Std::String
Get the string representation of a MPQ value in the given base.
init_set_d
Type: Std::F64 -> GMP.Q::MPQ
Creates a new MPQ value from a floating-point number.
Parameters
f: The floating-point number to be converted toMPQ.
init_set_si
Type: Std::I64 -> Std::U64 -> GMP.Q::MPQ
Creates a new MPQ value from I64 numerator and denominator.
Parameters
num: The numerator as anI64value.den: The denominator as anU64value.
init_set_str
Type: Std::String -> Std::I64 -> Std::Option GMP.Q::MPQ
Creates new MPQ value from a string representation.
Parameters
str: The string representation of the rational number.base: The base of the string representation.
init_set_ui
Type: Std::U64 -> Std::U64 -> GMP.Q::MPQ
Creates a new MPQ value from an U64 value.
Parameters
num: The numerator as anU64value.den: The denominator as anU64value.
init_set_z
Type: GMP.Z::MPZ -> GMP.Q::MPQ
Creates a MPQ value by an MPZ value.
Parameters
val: TheMPZvalue to be converted to `MPQ
inv
Type: GMP.Q::MPQ -> GMP.Q::MPQ
Returns the multiplicative inverse of the MPQ value.
Parameters
num: TheMPQvalue to be inverted.
mpq
Type: Std::I64 -> Std::I64 -> GMP.Q::MPQ
Creates a new MPQ value from I64 numerator and denominator.
Parameters
num: The numerator as anI64value.den: The denominator as anI64value.
mul_2exp
Type: Std::U64 -> GMP.Q::MPQ -> GMP.Q::MPQ
Multiplies the MPQ value by 2^exp.
Parameters
exp: The exponent of 2.num: TheMPQvalue to be multiplied.
set_d
Type: Std::F64 -> GMP.Q::MPQ -> GMP.Q::MPQ
Sets the MPQ value to a floating-point number.
Parameters
f: The floating-point number to set.q: TheMPQvalue to be set.
set_si
Type: Std::I64 -> Std::U64 -> GMP.Q::MPQ -> GMP.Q::MPQ
Sets the MPQ value to a rational number represented by an I64 numerator and an U64 denominator.
Parameters
num: The numerator as anI64value.den: The denominator as anU64value.q: TheMPQvalue to be set.
set_str
Type: Std::String -> Std::I64 -> GMP.Q::MPQ -> Std::Option GMP.Q::MPQ
Sets the MPQ value from a string representation.
Parameters
str: The string representation of the rational number.base: The base of the string representation.q: TheMPQvalue to be set.
set_ui
Type: Std::U64 -> Std::U64 -> GMP.Q::MPQ -> GMP.Q::MPQ
Sets the MPQ value to a rational number represented by an U64 numerator and an U64 denominator.
Parameters
num: The numerator as anU64value.den: The denominator as anU64value.q: TheMPQvalue to be set.
set_z
Type: GMP.Z::MPZ -> GMP.Q::MPQ -> GMP.Q::MPQ
Sets the MPQ value to an MPZ value.
Parameters
z: TheMPZvalue to be set.q: TheMPQvalue to be set.
sgn
Type: GMP.Q::MPQ -> Std::I64
Returns the sign of a MPQ value.
Returns
-1ifn < 00ifn == 01ifn > 0
Types and aliases
namespace GMP.Q
MPQ
Defined as: type MPQ = unbox struct { ...fields... }
Rational number type, represented by a pair of MPZ values (numerator and denominator).
field _0
Type: Std::FFI::Destructor GMP.Q::MPQHandle
MPQHandle
Defined as: type MPQHandle = Std::Ptr
A pointer to struct __mpq_struct.