ConvertGMP function

Convert Between Real, Integer, and GMP Rational

Convert Between Real, Integer, and GMP Rational

Converts to and from GMP (GNU multiple precision) rational numbers. Any size integers in the numerator and denominator are allowed.

d2q(x) q2d(x) q2q(x) z2q(numer, denom, canonicalize = TRUE)

Arguments

  • x,numer,denom: objects of type "numeric"

    or "character".

  • canonicalize: if TRUE (the default) canonicalize (see below).

Returns

d2q converts from real to rational, q2d converts from rational to real, q2q canonicalizes (no common factors in numerator and denominator) rationals, z2q converts integer numerator and denominator to rational canonicalizing if canonicalize = TRUE (the default).

See Also

ArithmeticGMP

Examples

d2q(runif(1)) q2d("-123456789123456789987654321/33") z2q(44, 11)
  • Maintainer: Charles J. Geyer
  • License: GPL-2
  • Last published: 2023-12-15