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 TypeMethodDescriptionint
abs
(int round) Takes the absolute value of this.int
Sets this to |op|.int
Sets this to the arc-cosine of op.int
Sets this to the hyperbolic arc-cosine of op.int
add
(double op, int round) Adds op to this.int
add
(int op, int round) Adds op to this.int
Sets this to op1+op2.int
Adds op to this.int
Sets this to op1+op2.int
Sets this to op1+op2.int
Sets this to op1+op2.int
Sets this to op1+op2.int
Adds op to this.int
Adds op to this.int
Sets this to the arithmetic-geometric mean of op1 and op2.int
Sets this to the arc-sine of op.int
Sets this to the hyperbolic arc-sine of op.int
Sets this to the arc-tangent of op.int
Sets this to the arc-tangent2 of y and x.int
Sets this to the hyperbolic arc-tangent of op.boolean
canRound
(int err, int round1, int round2, int prec) Whether this can be rounded without loss of precision.int
cbrt
(int round) Takes the cubic root of this.int
Sets this to the cubic root of op.int
Stores into this, op rounded to the next representable integer.int
checkRange
(int t, int round) Forces this to be in the current range of acceptable values.static void
Clears the erange (invalid range) flag.static void
Clears the inexact flag.static void
Clears the invalid flag.static void
Clears the overflow flag.static void
Clears the underflow flag.clone()
Creates a new Mpfr initialized with the value of this.int
cmp
(double op) Compares this to op.int
cmp
(int op) Compares this to op.int
Compares this to op.int
Compares this to op.int
Compares this to op.int
cmp2exp
(int op, int e) Compares this to op*2^e.int
Compares |this| to |op|.int
Compare the value of this and x.int
constCatalan
(int round) Sets this to Catalan's constant.int
constEuler
(int round) Sets this to Euler's constant.int
constLog2
(int round) Sets this to the constant log(2).int
constPi
(int round) Sets this to the constant pi.int
Sets this to op1 (rounded), and then sets the bit-sign of this to that of op2.int
Sets this to the cosine of op.int
Sets this to the hyperbolic cosine of op.int
Sets this to the cotangent of op.int
Sets this to the hyperbolic cotangent of op.int
Sets this to the cosecant op.int
Sets this to the hyperbolic cosecant op.int
Sets this to max(0, op1-op2).int
div
(double op, int round) Divides this by op.int
Sets this to op1/op2.int
div
(int op, int round) Divides this by op.int
Sets this to op1/op2.int
Sets this to op1/op2.int
Divides this by op.int
Sets this to op1/op2.int
Sets this to op1/op2.int
Sets this to op1/op2.int
Sets this to op1/op2.int
Divides this by op.int
Divides this by op.int
div2exp
(int op, int round) Divides this by 2^op.int
Sets this to op1/(2^op2).int
divRev
(double op, int round) Stores op/this into this.int
divRev
(int op, int round) Stores op/this into this.double
doubleExponentValue
(int[] r, int round) Converts the integer to a mantissa and exponent.double
doubleValue
(int round) Returns this as a double (with rounding).int
Sets this to the exponential integral of op.boolean
Whether x is a Mpfr and has the same value as this.int
Sets this to the value of the error function at op.int
Sets this to the value of the complementary error function at op.int
Sets this to e^op.int
Sets this to 10^op.int
Sets this to 2^op.int
Sets this to exp(op-1).int
fac
(int i, int round) Sets this to i!.boolean
fitsInt
(int round) Whether this converted to integer (with rounding) fits in an int.int
Stores into this, op rounded to the previous representable integer.int
Sets this to (op1*op2)+op3.int
Sets this to x-y*trunc(x/y).int
Sets this to (op1*op2)-op3.int
Stores into this, the fractional part of op with the same sign as op, and rounded.static void
Free various caches used internally to compute functions and constants.int
Sets this to the value of the Gamma function at op.static int
Returns the default precision, in bits.static long
getEmax()
Returns the current largest exponent allowed for a floating-point variable.static long
Returns the largest value allowed insetEmax(long)
.static long
Returns the smallest value allowed insetEmax(long)
.static long
getEmin()
Returns the current smallest exponent allowed for a floating-point variable.static long
Returns the largest value allowed insetEmin(long)
.static long
Returns the smallest value allowed insetEmin(long)
.int
getExp()
Returns the exponent of this.static String
Returns the ids of the patches applied to the MPFR library.int
getPrec()
Returns the precision of this, in bits.static String
Returns the MPFR version.int
hashCode()
Returns a hash of the value of this.int
Sets this to the Euclidean norm of x and y.int
intValue
(int round) Returns this as an integer (with rounding).boolean
Whether this == op.static boolean
Returns the erange (invalid range) flag.boolean
Whether this > op.boolean
isGreaterEqual
(Mpfr op) Whether this >= op.static boolean
Returns the inexact flag.boolean
isInf()
Returns true if this is an infinity.boolean
Whether this is an integer.boolean
Whether this < op.boolean
isLessEqual
(Mpfr op) Whether this <= op.boolean
isLessGreater
(Mpfr op) Whether this < op or this > op.boolean
isNaN()
Returns true if this is a NaN.static boolean
Returns the invalid flag.boolean
isNumber()
Returns true if this is a regular number (non-infinity or NaN).static boolean
Returns the overflow flag.boolean
Whether this and x have the same address in memory.static boolean
Returns the underflow flag.boolean
isUnordered
(Mpfr op) Whether this or op is a NaN.boolean
isZero()
Returns true if this is +0 or -0.int
Sets this to the value of the first kind Bessel function of order 0 at op.int
Sets this to the value of the first kind Bessel function of order 1 at op.int
Sets this to the value of the first kind Bessel function of order n at op.int
Sets this to the logarithm of the absolute value of the Gamma function at op.int
Sets this to the real part of the dilogarithm of op.int
Sets this to the logarithm of the value of the Gamma function at op.int
Sets this to the natural logarithm of op.int
Sets this to the logarithm in base 10 of op.int
Sets this to log(1+op).int
Sets this to the logarithm in base 2 of op.int
Sets this to the maximum of op1 and op2.int
Sets this to the minimum of op1 and op2.int
Sets this to the integral part of op, and f to its fractional part.int
Converts 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.int
mul
(double op, int round) Multiplies op by this.int
mul
(int op, int round) Multiplies op by this.int
Sets this to op1*op2.int
Multiplies op by this.int
Sets this to op1*op2.int
Sets this to op1*op2.int
Sets this to op1*op2.int
Sets this to op1*op2.int
Multiplies op by this.int
Multiplies op by this.int
mul2exp
(int op, int round) Multiplies this by 2^op.int
Sets this to op1*(2^op2).int
neg
(int round) Negates this.int
Sets this to -op.void
Sets this to the representable float following x.void
Sets this to the representable float preceding x.void
nextToward
(Mpfr op) Sets this to the next representable float following x in the direction of y.int
Stores op1^op2 into this.int
Stores op1^op2 into this.int
Stores op1^op2 into this.int
precRound
(int prec, int round) Rounds this to prec bits and changes its precision.int
Stores into this a uniformly distributed random number in [0, 1].int
recSqrt
(int round) Takes the inverted square root of this.int
Sets this to the inverted square root of op.int
Sets this to x-y*round(x/y).int
Sets this to x-y*round(x/y).int
Stores into this, op rounded to the nearest representable integer for the given rounding mode.int
Stores into this, the integer following op, then rounded.int
rint_floor
(Mpfr op, int round) Stores into this, the integer preceding op, then rounded.int
rint_round
(Mpfr op, int round) Stores into this, the integer nearest op, then rounded.int
rint_trunc
(Mpfr op, int round) Stores into this, op truncated to an integer, then rounded.int
root
(int k, int round) Takes the k-th root of this.int
Sets this to the k-th root of op.int
Stores into this, op rounded to the nearest representable integer.int
Sets this to the secant of op.int
Sets this to the hyperbolic secant of op.int
set
(double v, int round) Sets this to a double (with rounding).int
set
(int v, int round) Sets this to an integer (with rounding).int
set
(int v, int e, int round) Sets this to a v*2^e (with rounding).void
Copies v into this, changing the precision of this to match that of v.int
Copies v into this (with rounding).int
Sets this to a fraction (with rounding).int
Sets this to an integer (with rounding).void
Sets this to the number represented in the decimal String s (with rounding).void
Sets this to the number represented in the String s in base b (with rounding).int
set
(BigInteger v, int round) Sets this to an integer (with rounding).static void
setDefaultPrec
(int prec) Sets the default precision to exactly prec bits.static boolean
setEmax
(long exp) Sets the current largest exponent allowed for a for a floating-point variable.static boolean
setEmin
(long exp) Sets the current smallest exponent allowed for a for a floating-point variable.static void
Sets the erange (invalid range) flag.boolean
setExp
(int e) Sets the exponent of this to e.static void
Sets the inexact flag.void
setInf
(int sign) Sets this to a signed infinity.void
setNaN()
Sets this to NaN.static void
Sets the invalid flag.static void
Sets the overflow flag.void
setPrec
(int prec) Changes the precision of this to exactly prec bits.int
Sets this to op (rounded) and then sets the bit-sign of this to s.static void
Sets the underflow flag.int
sgn()
Returns a positive value if this is positive, negative if this is negative, and null if this is zero or NaN.boolean
signBit()
Returns true if this has its sign bit set.int
Sets this to the sine of op.int
Sets this to the sine of op, and c to its cosine.int
Sets this to the hyperbolic sine of op.int
Sets this to the hyperbolic sine of op, and c to its hyperbolic cosine.int
sqrt
(int round) Takes the square root of this.int
sqrt
(int op, int round) Sets this to the square root of op.int
Sets this to the square root of op.int
sub
(double op, int round) Subtracts op from this.int
Sets this to op1-op2.int
sub
(int op, int round) Subtracts op from this.int
Sets this to op1-op2.int
Sets this to op1-op2.int
Subtracts op from this.int
Sets this to op1-op2.int
Sets this to op1-op2.int
Sets this to op1-op2.int
Sets this to op1-op2.int
Subtracts op from this.int
Subtracts op from this.int
subNormalize
(int t, int round) Rounds this to emulate subnormal arithmetic.int
subRev
(double op, int round) Stores op-this into this.int
subRev
(int op, int round) Stores op-this into this.int
Stores into this the sum of an array or Mpfr (correctly rounded).int
Sets 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 String
toStringRndMode
(int round) Returns the name of the rounding mode.int
Stores into this, op truncated to a representable integer.int
Sets this to the value of the second kind Bessel function of order 0 at op.int
Sets this to the value of the second kind Bessel function of order 1 at op.int
Sets this to the value of the second kind Bessel function of order n at op.int
zeta
(int op, int round) Sets this to the value of the Riemann Zeta function at op.int
Sets 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:
clone
in 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:
compareTo
in 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].
-