Class Mpfr
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Mpfr>
This class wraps mpfr_t MPFR objects.
The precision of each number is set at construction time and not
changed when the number is modified (except by setPrec(int) or
set(Mpfr)).
Thus, most operators entail rounding. Such operators take as (last)
argument a rounding direction that can be RNDN, RNDZ,
RNDU, or RNDD).
Most operators return an integer that tells whether the stored result is exact (zero returned), over-approximated (positive number returned), or under-approximated (negative number returned).
In addition, the class has some global (static) exception flags that can be set by methods to denote IEEE 754 exceptions, and then inspected and reset by the user: overflow, underflow, NaN, inexact, and erange (invalid range) flags (these do not cause Java exceptions to be thrown).
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMpfr()Constructs a new number with the default precision.Mpfr(double v, int round) Constructs a float with the default precision equal to a double (with rounding).Mpfr(int prec) Constructs a new number with exactly prec bits of precision.Mpfr(int v, int round) Constructs a float with the default precision equal to an integer (with rounding).Constructs a copy of v, with the same precision as v.Constructs a copy of v, rounded to the default precision.Constructs a float with the default precision equal to a fraction (with rounding).Constructs a float with the default precision equal to an integer (with rounding).Constructs a float with the default precision equal to the number represented in the decimal String s (with rounding).Constructs a float with the default precision equal to the number represented in the String s in base b (with rounding).Mpfr(BigInteger v, int round) Constructs a float with the default precision equal to an integer (with rounding). -
Method Summary
Modifier and TypeMethodDescriptionintabs(int round) Takes the absolute value of this.intSets this to |op|.intSets this to the arc-cosine of op.intSets this to the hyperbolic arc-cosine of op.intadd(double op, int round) Adds op to this.intadd(int op, int round) Adds op to this.intSets this to op1+op2.intAdds op to this.intSets this to op1+op2.intSets this to op1+op2.intSets this to op1+op2.intSets this to op1+op2.intAdds op to this.intAdds op to this.intSets this to the arithmetic-geometric mean of op1 and op2.intSets this to the arc-sine of op.intSets this to the hyperbolic arc-sine of op.intSets this to the arc-tangent of op.intSets this to the arc-tangent2 of y and x.intSets this to the hyperbolic arc-tangent of op.booleancanRound(int err, int round1, int round2, int prec) Whether this can be rounded without loss of precision.intcbrt(int round) Takes the cubic root of this.intSets this to the cubic root of op.intStores into this, op rounded to the next representable integer.intcheckRange(int t, int round) Forces this to be in the current range of acceptable values.static voidClears the erange (invalid range) flag.static voidClears the inexact flag.static voidClears the invalid flag.static voidClears the overflow flag.static voidClears the underflow flag.clone()Creates a new Mpfr initialized with the value of this.intcmp(double op) Compares this to op.intcmp(int op) Compares this to op.intCompares this to op.intCompares this to op.intCompares this to op.intcmp2exp(int op, int e) Compares this to op*2^e.intCompares |this| to |op|.intCompare the value of this and x.intconstCatalan(int round) Sets this to Catalan's constant.intconstEuler(int round) Sets this to Euler's constant.intconstLog2(int round) Sets this to the constant log(2).intconstPi(int round) Sets this to the constant pi.intSets this to op1 (rounded), and then sets the bit-sign of this to that of op2.intSets this to the cosine of op.intSets this to the hyperbolic cosine of op.intSets this to the cotangent of op.intSets this to the hyperbolic cotangent of op.intSets this to the cosecant op.intSets this to the hyperbolic cosecant op.intSets this to max(0, op1-op2).intdiv(double op, int round) Divides this by op.intSets this to op1/op2.intdiv(int op, int round) Divides this by op.intSets this to op1/op2.intSets this to op1/op2.intDivides this by op.intSets this to op1/op2.intSets this to op1/op2.intSets this to op1/op2.intSets this to op1/op2.intDivides this by op.intDivides this by op.intdiv2exp(int op, int round) Divides this by 2^op.intSets this to op1/(2^op2).intdivRev(double op, int round) Stores op/this into this.intdivRev(int op, int round) Stores op/this into this.doubledoubleExponentValue(int[] r, int round) Converts the integer to a mantissa and exponent.doubledoubleValue(int round) Returns this as a double (with rounding).intSets this to the exponential integral of op.booleanWhether x is a Mpfr and has the same value as this.intSets this to the value of the error function at op.intSets this to the value of the complementary error function at op.intSets this to e^op.intSets this to 10^op.intSets this to 2^op.intSets this to exp(op-1).intfac(int i, int round) Sets this to i!.booleanfitsInt(int round) Whether this converted to integer (with rounding) fits in an int.intStores into this, op rounded to the previous representable integer.intSets this to (op1*op2)+op3.intSets this to x-y*trunc(x/y).intSets this to (op1*op2)-op3.intStores into this, the fractional part of op with the same sign as op, and rounded.static voidFree various caches used internally to compute functions and constants.intSets this to the value of the Gamma function at op.static intReturns the default precision, in bits.static longgetEmax()Returns the current largest exponent allowed for a floating-point variable.static longReturns the largest value allowed insetEmax(long).static longReturns the smallest value allowed insetEmax(long).static longgetEmin()Returns the current smallest exponent allowed for a floating-point variable.static longReturns the largest value allowed insetEmin(long).static longReturns the smallest value allowed insetEmin(long).intgetExp()Returns the exponent of this.static StringReturns the ids of the patches applied to the MPFR library.intgetPrec()Returns the precision of this, in bits.static StringReturns the MPFR version.inthashCode()Returns a hash of the value of this.intSets this to the Euclidean norm of x and y.intintValue(int round) Returns this as an integer (with rounding).booleanWhether this == op.static booleanReturns the erange (invalid range) flag.booleanWhether this > op.booleanisGreaterEqual(Mpfr op) Whether this >= op.static booleanReturns the inexact flag.booleanisInf()Returns true if this is an infinity.booleanWhether this is an integer.booleanWhether this < op.booleanisLessEqual(Mpfr op) Whether this <= op.booleanisLessGreater(Mpfr op) Whether this < op or this > op.booleanisNaN()Returns true if this is a NaN.static booleanReturns the invalid flag.booleanisNumber()Returns true if this is a regular number (non-infinity or NaN).static booleanReturns the overflow flag.booleanWhether this and x have the same address in memory.static booleanReturns the underflow flag.booleanisUnordered(Mpfr op) Whether this or op is a NaN.booleanisZero()Returns true if this is +0 or -0.intSets this to the value of the first kind Bessel function of order 0 at op.intSets this to the value of the first kind Bessel function of order 1 at op.intSets this to the value of the first kind Bessel function of order n at op.intSets this to the logarithm of the absolute value of the Gamma function at op.intSets this to the real part of the dilogarithm of op.intSets this to the logarithm of the value of the Gamma function at op.intSets this to the natural logarithm of op.intSets this to the logarithm in base 10 of op.intSets this to log(1+op).intSets this to the logarithm in base 2 of op.intSets this to the maximum of op1 and op2.intSets this to the minimum of op1 and op2.intSets this to the integral part of op, and f to its fractional part.intConverts exactly this to the form v*2^e, where v is an integer.MpzValue(int round) Converts this to an integer (with rounding) and returns it.intmul(double op, int round) Multiplies op by this.intmul(int op, int round) Multiplies op by this.intSets this to op1*op2.intMultiplies op by this.intSets this to op1*op2.intSets this to op1*op2.intSets this to op1*op2.intSets this to op1*op2.intMultiplies op by this.intMultiplies op by this.intmul2exp(int op, int round) Multiplies this by 2^op.intSets this to op1*(2^op2).intneg(int round) Negates this.intSets this to -op.voidSets this to the representable float following x.voidSets this to the representable float preceding x.voidnextToward(Mpfr op) Sets this to the next representable float following x in the direction of y.intStores op1^op2 into this.intStores op1^op2 into this.intStores op1^op2 into this.intprecRound(int prec, int round) Rounds this to prec bits and changes its precision.intStores into this a uniformly distributed random number in [0, 1].intrecSqrt(int round) Takes the inverted square root of this.intSets this to the inverted square root of op.intSets this to x-y*round(x/y).intSets this to x-y*round(x/y).intStores into this, op rounded to the nearest representable integer for the given rounding mode.intStores into this, the integer following op, then rounded.intrint_floor(Mpfr op, int round) Stores into this, the integer preceding op, then rounded.intrint_round(Mpfr op, int round) Stores into this, the integer nearest op, then rounded.intrint_trunc(Mpfr op, int round) Stores into this, op truncated to an integer, then rounded.introot(int k, int round) Takes the k-th root of this.intSets this to the k-th root of op.intStores into this, op rounded to the nearest representable integer.intSets this to the secant of op.intSets this to the hyperbolic secant of op.intset(double v, int round) Sets this to a double (with rounding).intset(int v, int round) Sets this to an integer (with rounding).intset(int v, int e, int round) Sets this to a v*2^e (with rounding).voidCopies v into this, changing the precision of this to match that of v.intCopies v into this (with rounding).intSets this to a fraction (with rounding).intSets this to an integer (with rounding).voidSets this to the number represented in the decimal String s (with rounding).voidSets this to the number represented in the String s in base b (with rounding).intset(BigInteger v, int round) Sets this to an integer (with rounding).static voidsetDefaultPrec(int prec) Sets the default precision to exactly prec bits.static booleansetEmax(long exp) Sets the current largest exponent allowed for a for a floating-point variable.static booleansetEmin(long exp) Sets the current smallest exponent allowed for a for a floating-point variable.static voidSets the erange (invalid range) flag.booleansetExp(int e) Sets the exponent of this to e.static voidSets the inexact flag.voidsetInf(int sign) Sets this to a signed infinity.voidsetNaN()Sets this to NaN.static voidSets the invalid flag.static voidSets the overflow flag.voidsetPrec(int prec) Changes the precision of this to exactly prec bits.intSets this to op (rounded) and then sets the bit-sign of this to s.static voidSets the underflow flag.intsgn()Returns a positive value if this is positive, negative if this is negative, and null if this is zero or NaN.booleansignBit()Returns true if this has its sign bit set.intSets this to the sine of op.intSets this to the sine of op, and c to its cosine.intSets this to the hyperbolic sine of op.intSets this to the hyperbolic sine of op, and c to its hyperbolic cosine.intsqrt(int round) Takes the square root of this.intsqrt(int op, int round) Sets this to the square root of op.intSets this to the square root of op.intsub(double op, int round) Subtracts op from this.intSets this to op1-op2.intsub(int op, int round) Subtracts op from this.intSets this to op1-op2.intSets this to op1-op2.intSubtracts op from this.intSets this to op1-op2.intSets this to op1-op2.intSets this to op1-op2.intSets this to op1-op2.intSubtracts op from this.intSubtracts op from this.intsubNormalize(int t, int round) Rounds this to emulate subnormal arithmetic.intsubRev(double op, int round) Stores op-this into this.intsubRev(int op, int round) Stores op-this into this.intStores into this the sum of an array or Mpfr (correctly rounded).intSets this to the tangent of op.toString()Returns a String representation of this in base 10 (rounding to nearest).toString(int b, int n, int round) Returns a String representation (with rounding).static StringtoStringRndMode(int round) Returns the name of the rounding mode.intStores into this, op truncated to a representable integer.intSets this to the value of the second kind Bessel function of order 0 at op.intSets this to the value of the second kind Bessel function of order 1 at op.intSets this to the value of the second kind Bessel function of order n at op.intzeta(int op, int round) Sets this to the value of the Riemann Zeta function at op.intSets this to the value of the Riemann Zeta function at op.
-
Field Details
-
RNDN
public static final int RNDNRounds to nearest.- See Also:
-
RNDZ
public static final int RNDZRounds toward zero.- See Also:
-
RNDU
public static final int RNDURounds toward plus infinity.- See Also:
-
RNDD
public static final int RNDDRounds toward minus infinity.- See Also:
-
-
Constructor Details
-
Mpfr
public Mpfr()Constructs a new number with the default precision.It is set to NaN.
-
Mpfr
public Mpfr(int prec) Constructs a new number with exactly prec bits of precision.It is set to NaN.
-
Mpfr
Constructs a copy of v, with the same precision as v. -
Mpfr
Constructs a copy of v, rounded to the default precision. -
Mpfr
public Mpfr(int v, int round) Constructs a float with the default precision equal to an integer (with rounding). -
Mpfr
Constructs a float with the default precision equal to an integer (with rounding). -
Mpfr
Constructs a float with the default precision equal to an integer (with rounding). -
Mpfr
public Mpfr(double v, int round) Constructs a float with the default precision equal to a double (with rounding). -
Mpfr
Constructs a float with the default precision equal to a fraction (with rounding). -
Mpfr
Constructs a float with the default precision equal to the number represented in the String s in base b (with rounding). -
Mpfr
Constructs a float with the default precision equal to the number represented in the decimal String s (with rounding).
-
-
Method Details
-
clone
Creates a new Mpfr initialized with the value of this.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
setDefaultPrec
public static void setDefaultPrec(int prec) Sets the default precision to exactly prec bits.This only affects objects created after the call.
The default is 53 bits initially (i.e., same as double precision IEEE floats).
-
getDefaultPrec
public static int getDefaultPrec()Returns the default precision, in bits. -
setPrec
public void setPrec(int prec) Changes the precision of this to exactly prec bits.The value of this is lost and set to NaN.
-
getPrec
public int getPrec()Returns the precision of this, in bits. -
set
Copies v into this (with rounding). -
set
Copies v into this, changing the precision of this to match that of v. -
set
public int set(int v, int round) Sets this to an integer (with rounding). -
set
public int set(int v, int e, int round) Sets this to a v*2^e (with rounding). -
set
Sets this to an integer (with rounding). -
set
Sets this to an integer (with rounding). -
set
public int set(double v, int round) Sets this to a double (with rounding). -
set
Sets this to a fraction (with rounding). -
set
Sets this to the number represented in the String s in base b (with rounding). -
set
Sets this to the number represented in the decimal String s (with rounding). -
setInf
public void setInf(int sign) Sets this to a signed infinity. -
setNaN
public void setNaN()Sets this to NaN. -
intValue
public int intValue(int round) Returns this as an integer (with rounding).- See Also:
-
doubleValue
public double doubleValue(int round) Returns this as a double (with rounding). -
doubleExponentValue
public double doubleExponentValue(int[] r, int round) Converts the integer to a mantissa and exponent.The mantissa m returned is such that 0.5 <= |m| < 1, rounded to fit double.
The exponent is stored into r[0].
-
MpzValue
Converts this to an integer (with rounding) and returns it. -
MpzExponentValue
Converts exactly this to the form v*2^e, where v is an integer.v is stored into r while e is returned.
-
toString
Returns a String representation (with rounding).b is the base, between 2 and 62.
n is the number of digits to output, or 0 to denote sufficient precision so that it is possible to recover the original value when parsing using rounding to nearest.
-
toString
Returns a String representation of this in base 10 (rounding to nearest). -
fitsInt
public boolean fitsInt(int round) Whether this converted to integer (with rounding) fits in an int. -
add
Sets this to op1+op2. -
add
Sets this to op1+op2. -
add
Sets this to op1+op2. -
add
Sets this to op1+op2. -
add
Sets this to op1+op2. -
add
Adds op to this. -
add
public int add(int op, int round) Adds op to this. -
add
public int add(double op, int round) Adds op to this. -
add
Adds op to this. -
add
Adds op to this. -
sub
Sets this to op1-op2. -
sub
Sets this to op1-op2. -
sub
Sets this to op1-op2. -
sub
Sets this to op1-op2. -
sub
Sets this to op1-op2. -
sub
Sets this to op1-op2. -
sub
Sets this to op1-op2. -
sub
Subtracts op from this. -
sub
public int sub(int op, int round) Subtracts op from this. -
sub
public int sub(double op, int round) Subtracts op from this. -
sub
Subtracts op from this. -
sub
Subtracts op from this. -
subRev
public int subRev(int op, int round) Stores op-this into this. -
subRev
public int subRev(double op, int round) Stores op-this into this. -
mul
Sets this to op1*op2. -
mul
Sets this to op1*op2. -
mul
Sets this to op1*op2. -
mul
Sets this to op1*op2. -
mul
Sets this to op1*op2. -
mul
Multiplies op by this. -
mul
public int mul(int op, int round) Multiplies op by this. -
mul
public int mul(double op, int round) Multiplies op by this. -
mul
Multiplies op by this. -
mul
Multiplies op by this. -
div
Sets this to op1/op2. -
div
Sets this to op1/op2. -
div
Sets this to op1/op2. -
div
Sets this to op1/op2. -
div
Sets this to op1/op2. -
div
Sets this to op1/op2. -
div
Sets this to op1/op2. -
div
Divides this by op. -
div
public int div(int op, int round) Divides this by op. -
div
public int div(double op, int round) Divides this by op. -
div
Divides this by op. -
div
Divides this by op. -
divRev
public int divRev(int op, int round) Stores op/this into this. -
divRev
public int divRev(double op, int round) Stores op/this into this. -
sqrt
Sets this to the square root of op. -
sqrt
public int sqrt(int round) Takes the square root of this. -
sqrt
public int sqrt(int op, int round) Sets this to the square root of op. -
recSqrt
Sets this to the inverted square root of op. -
recSqrt
public int recSqrt(int round) Takes the inverted square root of this. -
cbrt
Sets this to the cubic root of op. -
cbrt
public int cbrt(int round) Takes the cubic root of this. -
root
Sets this to the k-th root of op.k must be positive.
-
root
public int root(int k, int round) Takes the k-th root of this.k must be positive.
-
pow
Stores op1^op2 into this. -
pow
Stores op1^op2 into this. -
pow
Stores op1^op2 into this. -
neg
Sets this to -op. -
neg
public int neg(int round) Negates this. -
abs
Sets this to |op|. -
abs
public int abs(int round) Takes the absolute value of this. -
dim
Sets this to max(0, op1-op2). -
mul2exp
Sets this to op1*(2^op2). -
mul2exp
public int mul2exp(int op, int round) Multiplies this by 2^op. -
div2exp
Sets this to op1/(2^op2). -
div2exp
public int div2exp(int op, int round) Divides this by 2^op. -
cmp
Compares this to op.Returns a strictly positive, null, or negative number when this is respectively strictly greater, equal, or strictly smalled than op.
A NaN causes erange to be set and 0 to be returned.
-
cmp
public int cmp(int op) Compares this to op.Returns a strictly positive, null, or negative number when this is respectively strictly greater, equal, or strictly smalled than op.
A NaN causes erange to be set and 0 to be returned.
-
cmp
public int cmp(double op) Compares this to op.Returns a strictly positive, null, or negative number when this is respectively strictly greater, equal, or strictly smalled than op.
A NaN causes erange to be set and 0 to be returned.
-
cmp
Compares this to op.Returns a strictly positive, null, or negative number when this is respectively strictly greater, equal, or strictly smalled than op.
A NaN causes erange to be set and 0 to be returned.
-
cmp
Compares this to op.Returns a strictly positive, null, or negative number when this is respectively strictly greater, equal, or strictly smalled than op.
A NaN causes erange to be set and 0 to be returned.
-
cmp2exp
public int cmp2exp(int op, int e) Compares this to op*2^e.Returns a strictly positive, null, or negative number when this is respectively strictly greater, equal, or strictly smalled than op*2^e.
A NaN causes erange to be set and 0 to be returned.
-
cmpAbs
Compares |this| to |op|. -
isNaN
public boolean isNaN()Returns true if this is a NaN. -
isInf
public boolean isInf()Returns true if this is an infinity. -
isNumber
public boolean isNumber()Returns true if this is a regular number (non-infinity or NaN). -
isZero
public boolean isZero()Returns true if this is +0 or -0. -
sgn
public int sgn()Returns a positive value if this is positive, negative if this is negative, and null if this is zero or NaN. -
isGreater
Whether this > op.false if any operand is NaN.
-
isGreaterEqual
Whether this >= op.false if any operand is NaN.
-
isLess
Whether this < op.false if any operand is NaN.
-
isLessEqual
Whether this <= op.false if any operand is NaN.
-
isLessGreater
Whether this < op or this > op.false if any operand is NaN.
-
isEqual
Whether this == op.false if any operand is NaN: we have NaN!=NaN.
-
isUnordered
Whether this or op is a NaN. -
equals
Whether x is a Mpfr and has the same value as this.This compares representations, and so, NaN is assumed equal to NaN (unlike
isEqual(gmp.Mpfr)that follows the IEEE 754 convention). -
compareTo
Compare the value of this and x.- Specified by:
compareToin interfaceComparable<Mpfr>- See Also:
-
hashCode
public int hashCode()Returns a hash of the value of this. -
isPhysicalEqual
Whether this and x have the same address in memory. -
log
Sets this to the natural logarithm of op. -
log2
Sets this to the logarithm in base 2 of op. -
log10
Sets this to the logarithm in base 10 of op. -
exp
Sets this to e^op. -
exp2
Sets this to 2^op. -
exp10
Sets this to 10^op. -
cos
Sets this to the cosine of op. -
sin
Sets this to the sine of op. -
tan
Sets this to the tangent of op. -
sec
Sets this to the secant of op. -
csc
Sets this to the cosecant op. -
cot
Sets this to the cotangent of op. -
sinCos
Sets this to the sine of op, and c to its cosine. -
acos
Sets this to the arc-cosine of op. -
asin
Sets this to the arc-sine of op. -
atan
Sets this to the arc-tangent of op. -
atan2
Sets this to the arc-tangent2 of y and x. -
cosh
Sets this to the hyperbolic cosine of op. -
sinh
Sets this to the hyperbolic sine of op. -
sinhCosh
Sets this to the hyperbolic sine of op, and c to its hyperbolic cosine. -
sech
Sets this to the hyperbolic secant of op. -
csch
Sets this to the hyperbolic cosecant op. -
coth
Sets this to the hyperbolic cotangent of op. -
acosh
Sets this to the hyperbolic arc-cosine of op. -
asinh
Sets this to the hyperbolic arc-sine of op. -
atanh
Sets this to the hyperbolic arc-tangent of op. -
fac
public int fac(int i, int round) Sets this to i!.i must be positive.
-
log1p
Sets this to log(1+op). -
expm1
Sets this to exp(op-1). -
eint
Sets this to the exponential integral of op. -
li2
Sets this to the real part of the dilogarithm of op. -
gamma
Sets this to the value of the Gamma function at op. -
lngamma
Sets this to the logarithm of the value of the Gamma function at op. -
lgamma
Sets this to the logarithm of the absolute value of the Gamma function at op.Also stores the sign of the value into sign[0].
-
zeta
Sets this to the value of the Riemann Zeta function at op. -
zeta
public int zeta(int op, int round) Sets this to the value of the Riemann Zeta function at op.op must be positive.
-
erf
Sets this to the value of the error function at op. -
erfc
Sets this to the value of the complementary error function at op. -
j0
Sets this to the value of the first kind Bessel function of order 0 at op. -
j1
Sets this to the value of the first kind Bessel function of order 1 at op. -
jn
Sets this to the value of the first kind Bessel function of order n at op. -
y0
Sets this to the value of the second kind Bessel function of order 0 at op. -
y1
Sets this to the value of the second kind Bessel function of order 1 at op. -
yn
Sets this to the value of the second kind Bessel function of order n at op. -
fma
Sets this to (op1*op2)+op3. -
fms
Sets this to (op1*op2)-op3. -
agm
Sets this to the arithmetic-geometric mean of op1 and op2. -
hypot
Sets this to the Euclidean norm of x and y. -
constLog2
public int constLog2(int round) Sets this to the constant log(2). -
constPi
public int constPi(int round) Sets this to the constant pi. -
constEuler
public int constEuler(int round) Sets this to Euler's constant. -
constCatalan
public int constCatalan(int round) Sets this to Catalan's constant. -
freeCache
public static void freeCache()Free various caches used internally to compute functions and constants. -
sum
Stores into this the sum of an array or Mpfr (correctly rounded). -
rint
Stores into this, op rounded to the nearest representable integer for the given rounding mode. -
ceil
Stores into this, op rounded to the next representable integer. -
floor
Stores into this, op rounded to the previous representable integer. -
round
Stores into this, op rounded to the nearest representable integer. -
trunc
Stores into this, op truncated to a representable integer. -
rint_ceil
Stores into this, the integer following op, then rounded. -
rint_floor
Stores into this, the integer preceding op, then rounded. -
rint_round
Stores into this, the integer nearest op, then rounded. -
rint_trunc
Stores into this, op truncated to an integer, then rounded. -
frac
Stores into this, the fractional part of op with the same sign as op, and rounded. -
modf
Sets this to the integral part of op, and f to its fractional part. -
fmod
Sets this to x-y*trunc(x/y). -
remainder
Sets this to x-y*round(x/y). -
remquo
Sets this to x-y*round(x/y).Stores into q[0] the low bits of the (signed) quotient round(x/y).
-
isInteger
public boolean isInteger()Whether this is an integer. -
precRound
public int precRound(int prec, int round) Rounds this to prec bits and changes its precision. -
canRound
public boolean canRound(int err, int round1, int round2, int prec) Whether this can be rounded without loss of precision.Assuming that this approximates some number x in the direction round1 with error at most 2^(expb-err), where expb is the exponent of b, returns true if x can be correctly rounded to prec bits in the direction round2. Does not modify this.
-
toStringRndMode
Returns the name of the rounding mode. -
nextToward
Sets this to the next representable float following x in the direction of y. -
nextAbove
public void nextAbove()Sets this to the representable float following x. -
nextBelow
public void nextBelow()Sets this to the representable float preceding x. -
min
Sets this to the minimum of op1 and op2. -
max
Sets this to the maximum of op1 and op2. -
getExp
public int getExp()Returns the exponent of this. -
setExp
public boolean setExp(int e) Sets the exponent of this to e. -
signBit
public boolean signBit()Returns true if this has its sign bit set. -
setSign
Sets this to op (rounded) and then sets the bit-sign of this to s. -
copySign
Sets this to op1 (rounded), and then sets the bit-sign of this to that of op2. -
getVersion
Returns the MPFR version. -
getPatches
Returns the ids of the patches applied to the MPFR library. -
getEmin
public static long getEmin()Returns the current smallest exponent allowed for a floating-point variable. -
getEmax
public static long getEmax()Returns the current largest exponent allowed for a floating-point variable. -
setEmin
public static boolean setEmin(long exp) Sets the current smallest exponent allowed for a for a floating-point variable.Returns true if the change was successful.
-
setEmax
public static boolean setEmax(long exp) Sets the current largest exponent allowed for a for a floating-point variable.Returns true if the change was successful.
-
getEminMin
public static long getEminMin()Returns the smallest value allowed insetEmin(long). -
getEminMax
public static long getEminMax()Returns the largest value allowed insetEmin(long). -
getEmaxMin
public static long getEmaxMin()Returns the smallest value allowed insetEmax(long). -
getEmaxMax
public static long getEmaxMax()Returns the largest value allowed insetEmax(long). -
checkRange
public int checkRange(int t, int round) Forces this to be in the current range of acceptable values. -
subNormalize
public int subNormalize(int t, int round) Rounds this to emulate subnormal arithmetic. -
clearUnderflow
public static void clearUnderflow()Clears the underflow flag. -
clearOverflow
public static void clearOverflow()Clears the overflow flag. -
clearNaNFlag
public static void clearNaNFlag()Clears the invalid flag. -
clearInexFlag
public static void clearInexFlag()Clears the inexact flag. -
clearERangeFlag
public static void clearERangeFlag()Clears the erange (invalid range) flag. -
setUnderflow
public static void setUnderflow()Sets the underflow flag. -
setOverflow
public static void setOverflow()Sets the overflow flag. -
setNaNFlag
public static void setNaNFlag()Sets the invalid flag. -
setInexFlag
public static void setInexFlag()Sets the inexact flag. -
setERangeFlag
public static void setERangeFlag()Sets the erange (invalid range) flag. -
isUnderflow
public static boolean isUnderflow()Returns the underflow flag. -
isOverflow
public static boolean isOverflow()Returns the overflow flag. -
isNaNFlag
public static boolean isNaNFlag()Returns the invalid flag. -
isInexFlag
public static boolean isInexFlag()Returns the inexact flag. -
isERangeFlag
public static boolean isERangeFlag()Returns the erange (invalid range) flag. -
random
Stores into this a uniformly distributed random number in [0, 1].
-