Class ApfloatMath
Due to different types of round-off errors that can occur in the implementation, no guarantees about e.g. monotonicity are given for any of the methods.
- Version:
- 1.10.1
- Author:
- Mikko Tommila
- See Also:
ApintMath
-
Method Summary
Modifier and TypeMethodDescriptionstatic Apfloat
Absolute value.static Apfloat
Inverse cosine.static Apfloat
Inverse hyperbolic cosine.static Apfloat
Arithmetic-geometric mean.static Apfloat
Inverse sine.static Apfloat
Inverse hyperbolic sine.static Apfloat
Inverse tangent.static Apfloat
Converts cartesian coordinates to polar coordinates.static Apfloat
Inverse hyperbolic tangent.static Apfloat
Cube root.static Apint
Ceiling function.static Apfloat
Copy sign from one argument to another.static Apfloat
Cosine.static Apfloat
Hyperbolic cosine.static Apfloat
euler(long precision)
Calculates γ, the Euler-Mascheroni constant.static Apfloat
euler(long precision, int radix)
Calculates γ, the Euler-Mascheroni constant.static Apfloat
Exponent function.static Apint
Floor function.static Apfloat
Returns x modulo y.static Apfloat
Extracts fractional part.static Apfloat
Gamma function.static Apfloat
Incomplete gamma function.static Apfloat
Generalized incomplete gamma function.static Apfloat
inverseRoot(Apfloat x, long n)
Inverse positive integer root.static Apfloat
inverseRoot(Apfloat x, long n, long targetPrecision)
Inverse positive integer root.static Apfloat
inverseRoot(Apfloat x, long n, long targetPrecision, Apfloat initialGuess)
Inverse positive integer root.static Apfloat
inverseRoot(Apfloat x, long n, long targetPrecision, Apfloat initialGuess, long initialPrecision)
Inverse positive integer root.static Apfloat
Natural logarithm.static Apfloat
Logarithm in arbitrary base.static Apfloat
logRadix(long precision, int radix)
Gets or calculates logarithm of a radix to required precision.static Apfloat
Returns the greater of the two values.static Apfloat
Returns the smaller of the two values.static Apfloat[]
Split to integer and fractional parts.static Apfloat
multiplyAdd(Apfloat a, Apfloat b, Apfloat c, Apfloat d)
Fused multiply-add.static Apfloat
multiplySubtract(Apfloat a, Apfloat b, Apfloat c, Apfloat d)
Fused multiply-subtract.static Apfloat
Deprecated.static Apfloat
Returns the number adjacent to the first argument in the direction of the second argument, considering the scale and precision of the first argument.static Apfloat
Returns the number adjacent to the argument in the direction of negative infinity, considering the scale and precision of the argument.static Apfloat
Returns the number adjacent to the argument in the direction of positive infinity, considering the scale and precision of the argument.static Apfloat
pi(long precision)
Calculates π.static Apfloat
pi(long precision, int radix)
Calculates π.static Apfloat
Integer power.static Apfloat
Arbitrary power.static Apfloat
Product of numbers.static Apfloat
random(long digits)
Generates a random number.static Apfloat
random(long digits, int radix)
Generates a random number.static Apfloat
randomGaussian(long digits)
Generates a random, Gaussian ("normally") distributed number value with mean 0 and standard deviation 1.static Apfloat
randomGaussian(long digits, int radix)
Generates a random, Gaussian ("normally") distributed number value with mean 0 and standard deviation 1.static Apfloat
Positive integer root.static Apfloat
round(Apfloat x, long precision, RoundingMode roundingMode)
Rounds the given number to the specified precision with the specified rounding mode.static Apfloat
Multiply by a power of the radix.static Apfloat
Sine.static Apfloat
Hyperbolic sine.static Apfloat
Square root.static Apfloat
Sum of numbers.static Apfloat
Tangent.static Apfloat
Hyperbolic tangent.static Apfloat
Converts an angle measured in radians to degrees.static Apfloat
Converts an angle measured in degrees to radians.static Apint
Truncates fractional part.static Apfloat
Returns the unit in the last place of the argument, considering the scale and precision.static Apfloat
Lambert W function.
-
Method Details
-
pow
Integer power.- Parameters:
x
- Base of the power operator.n
- Exponent of the power operator.- Returns:
x
to then
:th power, that isxn
.- Throws:
ArithmeticException
- If bothx
andn
are zero.ApfloatRuntimeException
-
sqrt
Square root.- Parameters:
x
- The argument.- Returns:
- Square root of
x
. - Throws:
ArithmeticException
- Ifx
is negative.ApfloatRuntimeException
-
cbrt
Cube root.- Parameters:
x
- The argument.- Returns:
- Cube root of
x
. - Throws:
ApfloatRuntimeException
-
root
Positive integer root.- Parameters:
x
- The argument.n
- Which root to take.- Returns:
n
:th root ofx
, that isx1/n
.- Throws:
ArithmeticException
- Ifn
is zero, orx
is negative andn
is even.ApfloatRuntimeException
-
inverseRoot
public static Apfloat inverseRoot(Apfloat x, long n) throws ArithmeticException, ApfloatRuntimeExceptionInverse positive integer root.- Parameters:
x
- The argument.n
- Which inverse root to take.- Returns:
- Inverse
n
:th root ofx
, that isx-1/n
. - Throws:
ArithmeticException
- Ifx
orn
is zero, orx
is negative andn
is even.ApfloatRuntimeException
-
inverseRoot
public static Apfloat inverseRoot(Apfloat x, long n, long targetPrecision) throws IllegalArgumentException, ArithmeticException, ApfloatRuntimeExceptionInverse positive integer root.- Parameters:
x
- The argument.n
- Which inverse root to take.targetPrecision
- Precision of the desired result.- Returns:
- Inverse
n
:th root ofx
, that isx-1/n
. - Throws:
IllegalArgumentException
- IftargetPrecision <= 0
.ArithmeticException
- Ifx
orn
is zero, orx
is negative andn
is even.ApfloatRuntimeException
-
inverseRoot
public static Apfloat inverseRoot(Apfloat x, long n, long targetPrecision, Apfloat initialGuess) throws IllegalArgumentException, ArithmeticException, ApfloatRuntimeExceptionInverse positive integer root.- Parameters:
x
- The argument.n
- Which inverse root to take.targetPrecision
- Precision of the desired result.initialGuess
- Initial guess for the result value, ornull
if none is available.- Returns:
- Inverse
n
:th root ofx
, that isx-1/n
. - Throws:
IllegalArgumentException
- IftargetPrecision <= 0
.ArithmeticException
- Ifx
orn
is zero, orx
is negative andn
is even.ApfloatRuntimeException
-
inverseRoot
public static Apfloat inverseRoot(Apfloat x, long n, long targetPrecision, Apfloat initialGuess, long initialPrecision) throws IllegalArgumentException, ArithmeticException, ApfloatRuntimeExceptionInverse positive integer root.This method is the basis for most of apfloat's non-elementary operations. It is used e.g. in
Apfloat.divide(Apfloat)
,sqrt(Apfloat)
androot(Apfloat,long)
.- Parameters:
x
- The argument.n
- Which inverse root to take.targetPrecision
- Precision of the desired result.initialGuess
- Initial guess for the result value, ornull
if none is available.initialPrecision
- Precision of the initial guess, if available.- Returns:
- Inverse
n
:th root ofx
, that isx-1/n
. - Throws:
IllegalArgumentException
- IftargetPrecision <= 0
orinitialPrecision <= 0
.ArithmeticException
- Ifx
orn
is zero, orx
is negative andn
is even.ApfloatRuntimeException
-
floor
Floor function. Returns the largest (closest to positive infinity) value that is not greater than the argument and is equal to a mathematical integer.- Parameters:
x
- The argument.- Returns:
x
rounded towards negative infinity.- Throws:
ApfloatRuntimeException
-
ceil
Ceiling function. Returns the smallest (closest to negative infinity) value that is not less than the argument and is equal to a mathematical integer.- Parameters:
x
- The argument.- Returns:
x
rounded towards positive infinity.- Throws:
ApfloatRuntimeException
-
truncate
Truncates fractional part.- Parameters:
x
- The argument.- Returns:
x
rounded towards zero.- Throws:
ApfloatRuntimeException
-
frac
Extracts fractional part.- Parameters:
x
- The argument.- Returns:
- The fractional part of
x
. - Throws:
ApfloatRuntimeException
- Since:
- 1.7.0
-
round
public static Apfloat round(Apfloat x, long precision, RoundingMode roundingMode) throws IllegalArgumentException, ArithmeticException, ApfloatRuntimeExceptionRounds the given number to the specified precision with the specified rounding mode.- Parameters:
x
- The number to round.precision
- The precision to round to.roundingMode
- The rounding mode to use.- Returns:
- The rounded number.
- Throws:
IllegalArgumentException
- Ifprecision
is less than zero or zero.ArithmeticException
- If rounding is necessary (result is not exact) and rounding mode isRoundingMode.UNNECESSARY
.ApfloatRuntimeException
- Since:
- 1.7.0
-
negate
Deprecated.UseApfloat.negate()
.Returns an apfloat whose value is-x
.- Parameters:
x
- The argument.- Returns:
-x
.- Throws:
ApfloatRuntimeException
-
abs
Absolute value.- Parameters:
x
- The argument.- Returns:
- Absolute value of
x
. - Throws:
ApfloatRuntimeException
-
copySign
Copy sign from one argument to another.- Parameters:
x
- The value whose sign is to be adjusted.y
- The value whose sign is to be used.- Returns:
x
with its sign changed to match the sign ofy
.- Throws:
ApfloatRuntimeException
- Since:
- 1.1
-
scale
Multiply by a power of the radix.- Parameters:
x
- The argument.scale
- The scaling factor.- Returns:
x * x.radix()scale
.- Throws:
ApfloatRuntimeException
-
modf
Split to integer and fractional parts. The integer part is simplyi = floor(x)
. For the fractional partf
the following is always true:0 <= f < 1
- Parameters:
x
- The argument.- Returns:
- An array of two apfloats,
[i, f]
, the first being the integer part and the last being the fractional part. - Throws:
ApfloatRuntimeException
-
fmod
Returns x modulo y.This function calculates the remainder
f
ofx / y
such thatx = i * y + f
, wherei
is an integer,f
has the same sign asx
, and the absolute value off
is less than the absolute value ofy
.If
y
is zero, then zero is returned.- Parameters:
x
- The dividend.y
- The divisor.- Returns:
- The remainder when x is divided by y.
- Throws:
ApfloatRuntimeException
-
multiplyAdd
public static Apfloat multiplyAdd(Apfloat a, Apfloat b, Apfloat c, Apfloat d) throws ApfloatRuntimeExceptionFused multiply-add. Calculatesa * b + c * d
so that the precision used in the multiplications is only what is needed for the end result. Performance can this way be better than by calculatinga.multiply(b).add(c.multiply(d))
.- Parameters:
a
- First argument.b
- Second argument.c
- Third argument.d
- Fourth argument.- Returns:
a * b + c * d
.- Throws:
ApfloatRuntimeException
-
multiplySubtract
public static Apfloat multiplySubtract(Apfloat a, Apfloat b, Apfloat c, Apfloat d) throws ApfloatRuntimeExceptionFused multiply-subtract. Calculatesa * b - c * d
so that the precision used in the multiplications is only what is needed for the end result. Performance can this way be better than by calculatinga.multiply(b).subtract(c.multiply(d))
.- Parameters:
a
- First argument.b
- Second argument.c
- Third argument.d
- Fourth argument.- Returns:
a * b - c * d
.- Throws:
ApfloatRuntimeException
-
agm
Arithmetic-geometric mean.- Parameters:
a
- First argument.b
- Second argument.- Returns:
- Arithmetic-geometric mean of a and b.
- Throws:
ApfloatRuntimeException
-
pi
public static Apfloat pi(long precision) throws IllegalArgumentException, NumberFormatException, ApfloatRuntimeExceptionCalculates π. Uses default radix.- Parameters:
precision
- Number of digits of π to calculate.- Returns:
- π accurate to
precision
digits, in the default radix. - Throws:
NumberFormatException
- If the default radix is not valid.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
-
pi
public static Apfloat pi(long precision, int radix) throws IllegalArgumentException, NumberFormatException, ApfloatRuntimeExceptionCalculates π.- Parameters:
precision
- Number of digits of π to calculate.radix
- The radix in which the number should be presented.- Returns:
- π accurate to
precision
digits, in baseradix
. - Throws:
NumberFormatException
- If the radix is not valid.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
-
log
Natural logarithm.The logarithm is calculated using the arithmetic-geometric mean. See the Borweins' book for the formula.
- Parameters:
x
- The argument.- Returns:
- Natural logarithm of
x
. - Throws:
ArithmeticException
- Ifx <= 0
.ApfloatRuntimeException
-
log
public static Apfloat log(Apfloat x, Apfloat b) throws ArithmeticException, ApfloatRuntimeExceptionLogarithm in arbitrary base.The logarithm is calculated using the arithmetic-geometric mean. See the Borweins' book for the formula.
- Parameters:
x
- The argument.b
- The base.- Returns:
- Base-
b
logarithm ofx
. - Throws:
ArithmeticException
- Ifx <= 0
orb <= 0
.ApfloatRuntimeException
- Since:
- 1.6
-
logRadix
Gets or calculates logarithm of a radix to required precision. The calculated value is stored in a cache for later usage.- Parameters:
precision
- The needed precision.radix
- The radix.- Returns:
- Natural logarithm of
radix
to the specified precision. - Throws:
NumberFormatException
- If the radix is invalid.ApfloatRuntimeException
-
exp
Exponent function. Calculated using Newton's iteration for the inverse of logarithm.- Parameters:
x
- The argument.- Returns:
ex
.- Throws:
ApfloatRuntimeException
-
pow
public static Apfloat pow(Apfloat x, Apfloat y) throws ArithmeticException, ApfloatRuntimeExceptionArbitrary power. Calculated usinglog()
andexp()
.This method doesn't calculate the result properly if
x
is negative andy
is an integer. For that you should usepow(Apfloat,long)
.- Parameters:
x
- The base.y
- The exponent.- Returns:
xy
.- Throws:
ArithmeticException
- If bothx
andy
are zero, orx
is negative.ApfloatRuntimeException
-
acosh
Inverse hyperbolic cosine. Calculated usinglog()
.- Parameters:
x
- The argument.- Returns:
- Inverse hyperbolic cosine of
x
. - Throws:
ArithmeticException
- Ifx < 1
.ApfloatRuntimeException
-
asinh
Inverse hyperbolic sine. Calculated usinglog()
.- Parameters:
x
- The argument.- Returns:
- Inverse hyperbolic sine of
x
. - Throws:
ApfloatRuntimeException
-
atanh
Inverse hyperbolic tangent. Calculated usinglog()
.- Parameters:
x
- The argument.- Returns:
- Inverse hyperbolic tangent of
x
. - Throws:
ArithmeticException
- Ifabs(x) >= 1
.ApfloatRuntimeException
-
cosh
Hyperbolic cosine. Calculated usingexp()
.- Parameters:
x
- The argument.- Returns:
- Hyperbolic cosine of
x
. - Throws:
ApfloatRuntimeException
-
sinh
Hyperbolic sine. Calculated usingexp()
.- Parameters:
x
- The argument.- Returns:
- Hyperbolic sine of
x
. - Throws:
ApfloatRuntimeException
-
tanh
Hyperbolic tangent. Calculated usingexp()
.- Parameters:
x
- The argument.- Returns:
- Hyperbolic tangent of
x
. - Throws:
ApfloatRuntimeException
-
acos
Inverse cosine. Calculated using complex functions.- Parameters:
x
- The argument.- Returns:
- Inverse cosine of
x
. - Throws:
ArithmeticException
- Ifabs(x) > 1
.ApfloatRuntimeException
-
asin
Inverse sine. Calculated using complex functions.- Parameters:
x
- The argument.- Returns:
- Inverse sine of
x
. - Throws:
ArithmeticException
- Ifabs(x) > 1
.ApfloatRuntimeException
-
atan
Inverse tangent. Calculated using complex functions.- Parameters:
x
- The argument.- Returns:
- Inverse tangent of
x
. - Throws:
ApfloatRuntimeException
-
atan2
public static Apfloat atan2(Apfloat y, Apfloat x) throws ArithmeticException, ApfloatRuntimeExceptionConverts cartesian coordinates to polar coordinates. Calculated using complex functions.Computes the phase angle by computing an arc tangent of
y/x
in the range of -π < angle <= π.- Parameters:
y
- The argument.x
- The argument.- Returns:
- The angle of the point
(x, y)
in the plane. - Throws:
ArithmeticException
- Ify
andx
are both zero.ApfloatRuntimeException
-
cos
Cosine. Calculated using complex functions.- Parameters:
x
- The argument (in radians).- Returns:
- Cosine of
x
. - Throws:
ApfloatRuntimeException
-
sin
Sine. Calculated using complex functions.- Parameters:
x
- The argument (in radians).- Returns:
- Sine of
x
. - Throws:
ApfloatRuntimeException
-
tan
Tangent. Calculated using complex functions.- Parameters:
x
- The argument (in radians).- Returns:
- Tangent of
x
. - Throws:
ArithmeticException
- Ifx
is π/2 + n π where n is an integer.ApfloatRuntimeException
-
w
Lambert W function. The W function gives the solution to the equationW eW = x
. Also known as the product logarithm.This function only gives the solution to the principal branch, W0. For the real-valued W-1 branch, use
ApcomplexMath.w(Apcomplex,long)
.- Parameters:
x
- The argument.- Returns:
W0(x)
.- Throws:
ArithmeticException
- Ifx
is less than -1/e.ApfloatRuntimeException
- Since:
- 1.8.0
-
toDegrees
Converts an angle measured in radians to degrees.- Parameters:
x
- The angle, in radians.- Returns:
- The angle in degrees.
- Throws:
ApfloatRuntimeException
- Since:
- 1.8.0
-
toRadians
Converts an angle measured in degrees to radians.- Parameters:
x
- The angle, in degrees.- Returns:
- The angle in radians.
- Throws:
ApfloatRuntimeException
- Since:
- 1.8.0
-
product
Product of numbers. The precision used in the multiplications is only what is needed for the end result. This method may perform significantly better than simply multiplying the numbers sequentially.If there are no arguments, the return value is
1
.- Parameters:
x
- The argument(s).- Returns:
- The product of the given numbers.
- Throws:
ApfloatRuntimeException
- Since:
- 1.3
-
sum
Sum of numbers. The precision used in the additions is only what is needed for the end result. This method may perform significantly better than simply adding the numbers sequentially.If there are no arguments, the return value is
0
.- Parameters:
x
- The argument(s).- Returns:
- The sum of the given numbers.
- Throws:
ApfloatRuntimeException
- Since:
- 1.3
-
euler
Calculates γ, the Euler-Mascheroni constant. Uses default radix. This implementation is slow, meaning that it isn't a fast algorithm.- Parameters:
precision
- Number of digits of γ to calculate.- Returns:
- γ accurate to
precision
digits, in the default radix. - Throws:
NumberFormatException
- If the default radix is not valid.IllegalArgumentException
- In case the precision is invalid.- Since:
- 1.10.0
-
euler
public static Apfloat euler(long precision, int radix) throws IllegalArgumentException, NumberFormatException, ApfloatRuntimeExceptionCalculates γ, the Euler-Mascheroni constant.This implementation is slow, meaning that it isn't a fast algorithm.
- Parameters:
precision
- Number of digits of γ to calculate.radix
- The radix in which the number should be presented.- Returns:
- γ accurate to
precision
digits, in baseradix
. - Throws:
NumberFormatException
- If the radix is not valid.IllegalArgumentException
- In case the precision is invalid.ApfloatRuntimeException
- Since:
- 1.10.0
-
gamma
Gamma function.This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is something like O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the gamma function.
- Parameters:
x
- The argument.- Returns:
Γ(x)
- Throws:
ArithmeticException
- Ifx
is a nonpositive integer.- Since:
- 1.9.0
-
gamma
Incomplete gamma function.This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is something like O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the gamma function.
- Parameters:
a
- The first argument.x
- The second argument.- Returns:
Γ(a, x)
- Throws:
ArithmeticException
- Ifa
is not a positive integer andx
is nonpositive.- Since:
- 1.10.0
-
gamma
Generalized incomplete gamma function.This function is defined as:
Γ(a, x0, x1) = Γ(a, x0) - Γ(a, x1)
The lower gamma function can be calculated with:
γ(a, x) = Γ(a, 0, x)
This implementation is slow, meaning that it isn't a fast algorithm. The asymptotic complexity is something like O(n2log n) and it is impractically slow beyond a precision of a few thousand digits. At the time of implementation no generic fast algorithm is known for the gamma function.
- Parameters:
a
- The first argument.x0
- The second argument.x1
- The third argument.- Returns:
Γ(a, x0, x1)
- Throws:
ArithmeticException
- Ifa
is not a positive integer and eitherx0
orx1
is nonpositive.- Since:
- 1.10.0
-
random
Generates a random number. Uses the default radix. Returned values are chosen pseudorandomly with (approximately) uniform distribution from the range0 ≤ x < 1
. The generated random numbers may have leading zeros and may thus not always have exactly the requested number of significant digits. The precision of the numbers is the requested number of digits minus the number of leading zeros. Trailing zeros do not affect the precision.- Parameters:
digits
- Maximum number of digits in the number.- Returns:
- A random number, uniformly distributed between
0 ≤ x < 1
. - Throws:
NumberFormatException
- If the default radix is not valid.IllegalArgumentException
- In case the number of specified digits is invalid.- Since:
- 1.9.0
-
random
Generates a random number. Returned values are chosen pseudorandomly with (approximately) uniform distribution from the range0 ≤ x < 1
. The generated random numbers may have leading zeros and may thus not always have exactly the requested number of significant digits. The precision of the numbers is the requested number of digits minus the number of leading zeros. Trailing zeros do not affect the precision.- Parameters:
digits
- Maximum number of digits in the number.radix
- The radix in which the number should be generated.- Returns:
- A random number, uniformly distributed between
0 ≤ x < 1
, in baseradix
. - Throws:
NumberFormatException
- If the radix is not valid.IllegalArgumentException
- In case the number of specified digits is invalid.- Since:
- 1.9.0
-
randomGaussian
Generates a random, Gaussian ("normally") distributed number value with mean 0 and standard deviation 1. Uses the default radix.- Parameters:
digits
- Maximum number of digits in the number.- Returns:
- A random number, Gaussian ("normally") distributed with mean 0 and standard deviation 1.
- Throws:
NumberFormatException
- If the default radix is not valid.IllegalArgumentException
- In case the number of specified digits is invalid.- Since:
- 1.9.0
-
randomGaussian
Generates a random, Gaussian ("normally") distributed number value with mean 0 and standard deviation 1. Uses the default radix.- Parameters:
digits
- Maximum number of digits in the number.radix
- The radix in which the number should be generated.- Returns:
- A random number, Gaussian ("normally") distributed with mean 0 and standard deviation 1.
- Throws:
NumberFormatException
- If the radix is not valid.IllegalArgumentException
- In case the number of specified digits is invalid.- Since:
- 1.9.0
-
max
Returns the greater of the two values.- Parameters:
x
- An argument.y
- Another argument.- Returns:
- The greater of the two values.
- Since:
- 1.9.0
-
min
Returns the smaller of the two values.- Parameters:
x
- An argument.y
- Another argument.- Returns:
- The smaller of the two values.
- Since:
- 1.9.0
-
nextAfter
Returns the number adjacent to the first argument in the direction of the second argument, considering the scale and precision of the first argument. If the precision of the first argument is infinite, the first argument is returned. If both arguments compare as equal then the first argument is returned.- Parameters:
start
- The starting value.direction
- Value indicating which ofstart
's neighbors orstart
should be returned.- Returns:
- The number adjacent to
start
in the direction ofdirection
. - Since:
- 1.10.0
-
nextUp
Returns the number adjacent to the argument in the direction of positive infinity, considering the scale and precision of the argument. If the precision of the argument is infinite, the argument is returned.- Parameters:
x
- The starting value.- Returns:
- The adjacent value closer to positive infinity.
- Since:
- 1.10.0
-
nextDown
Returns the number adjacent to the argument in the direction of negative infinity, considering the scale and precision of the argument. If the precision of the argument is infinite, the argument is returned.- Parameters:
x
- The starting value.- Returns:
- The adjacent value closer to negative infinity.
- Since:
- 1.10.0
-
ulp
Returns the unit in the last place of the argument, considering the scale and precision. This is same as the difference between the argument and the value returned fromnextUp(Apfloat)
. If the precision of the argument is infinite, zero is returned.For example, ulp of
1.
is1
, ulp of1.1
is0.1
and ulp of1.001
is0.001
(considering significant digits only).- Parameters:
x
- The argument.- Returns:
- The ulp of the argument.
- Since:
- 1.10.0
-
Apfloat.negate()
.