public final class EFloat extends Object implements Comparable<EFloat>
Passing a signaling NaN to any arithmetic operation shown here will signal the flag FlagInvalid and return a quiet NaN, even if another operand to that operation is a quiet NaN, unless noted otherwise.
Passing a quiet NaN to any arithmetic operation shown here will return a quiet NaN, unless noted otherwise.
Unless noted otherwise, passing a null arbitrary-precision binary float argument to any method here will throw an exception.
When an arithmetic operation signals the flag FlagInvalid, FlagOverflow, or FlagDivideByZero, it will not throw an exception too, unless the operation's trap is enabled in the precision context (see EContext's Traps property).
An arbitrary-precision binary float value can be serialized in one of the following ways:
If an operation requires creating an intermediate value that might be too big to fit in memory (or might require more than 2 gigabytes of memory to store -- due to the current use of a 32-bit integer internally as a length), the operation may signal an invalid-operation flag and return not-a-number (NaN). In certain rare cases, the compareTo method may throw OutOfMemoryError (called OutOfMemoryError in Java) in the same circumstances.
Thread safety
Instances of this class are immutable, so they are inherently safe for use by multiple threads. Multiple instances of this object with the same properties are interchangeable, so they should not be compared using the "==" operator (which might only check if each side of the operator is the same instance).
Comparison considerations
This class's natural ordering (under the compareTo method) is not consistent with the Equals method. This means that two values that compare as equal under the compareTo method might not be equal under the Equals method. The compareTo method compares the mathematical values of the two instances passed to it (and considers two different NaN values as equal), while two instances with the same mathematical value, but different exponents, will be considered unequal under the Equals method.
| Modifier and Type | Field and Description |
|---|---|
static EFloat |
NaN
A not-a-number value.
|
static EFloat |
NegativeInfinity
Negative infinity, less than any other number.
|
static EFloat |
NegativeZero
Represents the number negative zero.
|
static EFloat |
One
Represents the number 1.
|
static EFloat |
PositiveInfinity
Positive infinity, greater than any other number.
|
static EFloat |
SignalingNaN
A not-a-number value that signals an invalid operation flag when it's
passed as an argument to any arithmetic operation in
arbitrary-precision binary float.
|
static EFloat |
Ten
Represents the number 10.
|
static EFloat |
Zero
Represents the number 0.
|
| Modifier and Type | Method and Description |
|---|---|
EFloat |
Abs()
Finds the absolute value of this object (if it's negative, it becomes
positive).
|
EFloat |
Abs(EContext context)
Finds the absolute value of this object (if it's negative, it becomes
positive).
|
EFloat |
Add(EFloat otherValue)
Adds this object and another binary float and returns the result.
|
EFloat |
Add(EFloat otherValue,
EContext ctx)
Finds the sum of this object and another object.
|
int |
compareTo(EFloat other)
Compares the mathematical values of this object and another object,
accepting NaN values.
|
EFloat |
CompareToSignal(EFloat other,
EContext ctx)
Compares the mathematical values of this object and another object, treating
quiet NaN as signaling.
|
int |
CompareToTotal(EFloat other)
Compares the values of this object and another object, imposing a total
ordering on all possible values.
|
int |
CompareToTotal(EFloat other,
EContext ctx)
Compares the values of this object and another object, imposing a total
ordering on all possible values.
|
int |
CompareToTotalMagnitude(EFloat other)
Compares the absolute values of this object and another object, imposing a
total ordering on all possible values (ignoring their signs).
|
EFloat |
CompareToWithContext(EFloat other,
EContext ctx)
Compares the mathematical values of this object and another object.
|
EFloat |
CopySign(EFloat other)
Returns a number with the same value as this one, but copying the sign
(positive or negative) of another number.
|
static EFloat |
Create(EInteger mantissa,
EInteger exponent)
Creates a number with the value exponent*2^mantissa (significand).
|
static EFloat |
Create(int mantissaSmall,
int exponentSmall)
Creates a number with the value exponent*2^mantissa (significand).
|
static EFloat |
CreateNaN(EInteger diag)
Creates a not-a-number arbitrary-precision binary float.
|
static EFloat |
CreateNaN(EInteger diag,
boolean signaling,
boolean negative,
EContext ctx)
Creates a not-a-number arbitrary-precision binary float.
|
EFloat |
Divide(EFloat divisor)
Divides this object by another binary float and returns the result.
|
EFloat |
Divide(EFloat divisor,
EContext ctx)
Divides this arbitrary-precision binary float by another arbitrary-precision
binary float.
|
EFloat[] |
DivideAndRemainderNaturalScale(EFloat divisor)
Deprecated.
Renamed to DivRemNaturalScale.
|
EFloat[] |
DivideAndRemainderNaturalScale(EFloat divisor,
EContext ctx)
Deprecated.
Renamed to DivRemNaturalScale.
|
EFloat |
DivideToExponent(EFloat divisor,
EInteger exponent,
EContext ctx)
Divides two arbitrary-precision binary floats, and gives a particular
exponent to the result.
|
EFloat |
DivideToExponent(EFloat divisor,
EInteger desiredExponent,
ERounding rounding)
Divides two arbitrary-precision binary floats, and gives a particular
exponent to the result.
|
EFloat |
DivideToExponent(EFloat divisor,
long desiredExponentSmall,
EContext ctx)
Divides two arbitrary-precision binary floats, and gives a particular
exponent to the result.
|
EFloat |
DivideToExponent(EFloat divisor,
long desiredExponentSmall,
ERounding rounding)
Divides two arbitrary-precision binary floats, and gives a particular
exponent to the result.
|
EFloat |
DivideToIntegerNaturalScale(EFloat divisor)
Divides two arbitrary-precision binary floats, and returns the integer part
of the result, rounded down, with the preferred exponent set to this
value's exponent minus the divisor's exponent.
|
EFloat |
DivideToIntegerNaturalScale(EFloat divisor,
EContext ctx)
Divides this object by another object, and returns the integer part of the
result (which is initially rounded down), with the preferred exponent
set to this value's exponent minus the divisor's exponent.
|
EFloat |
DivideToIntegerZeroScale(EFloat divisor,
EContext ctx)
Divides this object by another object, and returns the integer part of the
result, with the exponent set to 0.
|
EFloat |
DivideToSameExponent(EFloat divisor,
ERounding rounding)
Divides this object by another binary float and returns a result with the
same exponent as this object (the dividend).
|
EFloat[] |
DivRemNaturalScale(EFloat divisor)
Calculates the quotient and remainder using the DivideToIntegerNaturalScale
and the formula in RemainderNaturalScale.
|
EFloat[] |
DivRemNaturalScale(EFloat divisor,
EContext ctx)
Calculates the quotient and remainder using the DivideToIntegerNaturalScale
and the formula in RemainderNaturalScale.
|
boolean |
equals(EFloat other)
Determines whether this object's mantissa (significand), exponent, and
properties are equal to those of another object.
|
boolean |
equals(Object obj)
Determines whether this object's mantissa (significand), exponent, and
properties are equal to those of another object and that other object
is an arbitrary-precision binary float.
|
boolean |
EqualsInternal(EFloat otherValue)
Determines whether this object's mantissa (significand) and exponent
are equal to those of another object.
|
EFloat |
Exp(EContext ctx)
Finds e (the base of natural logarithms) raised to the power of this
object's value.
|
static EFloat |
FromByte(byte inputByte)
Converts a byte (from 0 to 255) to an arbitrary-precision binary float.
|
static EFloat |
FromDouble(double dbl)
Creates a binary float from a 64-bit floating-point number.
|
static EFloat |
FromEInteger(EInteger bigint)
Converts an arbitrary-precision integer to the same value as a binary float.
|
static EFloat |
FromInt16(short inputInt16)
Converts a 16-bit signed integer to an arbitrary-precision binary float.
|
static EFloat |
FromInt32(int inputInt32)
Converts a 32-bit signed integer to an arbitrary-precision binary float.
|
static EFloat |
FromInt64(long inputInt64)
Converts a 64-bit signed integer to an arbitrary-precision binary float.
|
static EFloat |
FromSingle(float flt)
Creates a binary float from a 32-bit floating-point number.
|
static EFloat |
FromString(String str)
Not documented yet.
|
static EFloat |
FromString(String str,
EContext ctx)
Creates a binary float from a text string that represents a number.
|
static EFloat |
FromString(String str,
int offset,
int length)
Creates a binary float from a text string that represents a number.
|
static EFloat |
FromString(String str,
int offset,
int length,
EContext ctx)
Creates a binary float from a text string that represents a number.
|
EInteger |
getExponent()
Gets this object's exponent.
|
EInteger |
getMantissa()
Gets this object's unscaled value.
|
EInteger |
getUnsignedMantissa()
Gets the absolute value of this object's unscaled value.
|
int |
hashCode()
Calculates this object's hash code.
|
boolean |
isFinite()
Gets a value indicating whether this object is finite (not infinity or NaN).
|
boolean |
IsInfinity()
Gets a value indicating whether this object is positive or negative
infinity.
|
boolean |
IsNaN()
Gets a value indicating whether this object is not a number (NaN).
|
boolean |
isNegative()
Gets a value indicating whether this object is negative, including negative
zero.
|
boolean |
IsNegativeInfinity()
Returns whether this object is negative infinity.
|
boolean |
IsPositiveInfinity()
Returns whether this object is positive infinity.
|
boolean |
IsQuietNaN()
Gets a value indicating whether this object is a quiet not-a-number value.
|
boolean |
IsSignalingNaN()
Gets a value indicating whether this object is a signaling not-a-number
value.
|
boolean |
isZero()
Gets a value indicating whether this object's value equals 0.
|
EFloat |
Log(EContext ctx)
Finds the natural logarithm of this object, that is, the power (exponent)
that e (the base of natural logarithms) must be raised to in order to
equal this object's value.
|
EFloat |
Log10(EContext ctx)
Finds the base-10 logarithm of this object, that is, the power (exponent)
that the number 10 must be raised to in order to equal this
object's value.
|
static EFloat |
Max(EFloat first,
EFloat second)
Gets the greater value between two binary floats.
|
static EFloat |
Max(EFloat first,
EFloat second,
EContext ctx)
Gets the greater value between two binary floats.
|
static EFloat |
MaxMagnitude(EFloat first,
EFloat second)
Gets the greater value between two values, ignoring their signs.
|
static EFloat |
MaxMagnitude(EFloat first,
EFloat second,
EContext ctx)
Gets the greater value between two values, ignoring their signs.
|
static EFloat |
Min(EFloat first,
EFloat second)
Gets the lesser value between two binary floats.
|
static EFloat |
Min(EFloat first,
EFloat second,
EContext ctx)
Gets the lesser value between two binary floats.
|
static EFloat |
MinMagnitude(EFloat first,
EFloat second)
Gets the lesser value between two values, ignoring their signs.
|
static EFloat |
MinMagnitude(EFloat first,
EFloat second,
EContext ctx)
Gets the lesser value between two values, ignoring their signs.
|
EFloat |
MovePointLeft(EInteger bigPlaces)
Returns a number similar to this number but with the radix point moved to
the left.
|
EFloat |
MovePointLeft(EInteger bigPlaces,
EContext ctx)
Returns a number similar to this number but with the radix point moved to
the left.
|
EFloat |
MovePointLeft(int places)
Returns a number similar to this number but with the radix point moved to
the left.
|
EFloat |
MovePointLeft(int places,
EContext ctx)
Returns a number similar to this number but with the radix point moved to
the left.
|
EFloat |
MovePointRight(EInteger bigPlaces)
Returns a number similar to this number but with the radix point moved to
the right.
|
EFloat |
MovePointRight(EInteger bigPlaces,
EContext ctx)
Returns a number similar to this number but with the radix point moved to
the right.
|
EFloat |
MovePointRight(int places)
Returns a number similar to this number but with the radix point moved to
the right.
|
EFloat |
MovePointRight(int places,
EContext ctx)
Returns a number similar to this number but with the radix point moved to
the right.
|
EFloat |
Multiply(EFloat otherValue)
Multiplies two binary floats.
|
EFloat |
Multiply(EFloat op,
EContext ctx)
Multiplies two binary floats.
|
EFloat |
MultiplyAndAdd(EFloat multiplicand,
EFloat augend)
Multiplies by one binary float, and then adds another binary float.
|
EFloat |
MultiplyAndAdd(EFloat op,
EFloat augend,
EContext ctx)
Multiplies by one value, and then adds another value.
|
EFloat |
MultiplyAndSubtract(EFloat op,
EFloat subtrahend,
EContext ctx)
Multiplies by one value, and then subtracts another value.
|
EFloat |
Negate()
Gets an object with the same value as this one, but with the sign reversed.
|
EFloat |
Negate(EContext context)
Returns a binary float with the same value as this object but with the sign
reversed.
|
EFloat |
NextMinus(EContext ctx)
Finds the largest value that's smaller than the given value.
|
EFloat |
NextPlus(EContext ctx)
Finds the smallest value that's greater than the given value.
|
EFloat |
NextToward(EFloat otherValue,
EContext ctx)
Finds the next value that is closer to the other object's value than
this object's value.
|
static EFloat |
PI(EContext ctx)
Finds the constant π, the circumference of a circle divided by its
diameter.
|
EFloat |
Plus(EContext ctx)
Rounds this object's value to a given precision, using the given
rounding mode and range of exponent, and also converts negative zero
to positive zero.
|
EFloat |
Pow(EFloat exponent,
EContext ctx)
Raises this object's value to the given exponent.
|
EFloat |
Pow(int exponentSmall)
Raises this object's value to the given exponent.
|
EFloat |
Pow(int exponentSmall,
EContext ctx)
Raises this object's value to the given exponent.
|
EInteger |
Precision()
Finds the number of digits in this number's mantissa (significand).
|
EFloat |
Quantize(EFloat otherValue,
EContext ctx)
Returns a binary float with the same value as this object but with the same
exponent as another binary float.
|
EFloat |
Quantize(EInteger desiredExponent,
EContext ctx)
Returns a binary float with the same value but a new exponent.
|
EFloat |
Quantize(int desiredExponentInt,
EContext ctx)
Returns a binary float with the same value but a new exponent.
|
EFloat |
Reduce(EContext ctx)
Removes trailing zeros from this object's mantissa (significand).
|
EFloat |
Remainder(EFloat divisor,
EContext ctx)
Finds the remainder that results when dividing two arbitrary-precision
binary floats.
|
EFloat |
RemainderNaturalScale(EFloat divisor)
Calculates the remainder of a number by the formula
"this" - (("this" /
"divisor") * "divisor") |
EFloat |
RemainderNaturalScale(EFloat divisor,
EContext ctx)
Calculates the remainder of a number by the formula "this" - (("this" /
"divisor") * "divisor").
|
EFloat |
RemainderNear(EFloat divisor,
EContext ctx)
Finds the distance to the closest multiple of the given divisor, based on
the result of dividing this object's value by another
object's value.
|
EFloat |
RoundToExponent(EInteger exponent,
EContext ctx)
Returns a binary float with the same value as this object but rounded to a
new exponent if necessary.
|
EFloat |
RoundToExponent(int exponentSmall,
EContext ctx)
Returns a binary float with the same value as this object but rounded to a
new exponent if necessary.
|
EFloat |
RoundToExponentExact(EInteger exponent,
EContext ctx)
Returns a binary float with the same value as this object but rounded to the
given exponent, and signals an inexact flag if the result would be
inexact.
|
EFloat |
RoundToExponentExact(EInteger exponent,
ERounding rounding)
Returns a binary number with the same value as this object but rounded to
the given exponent.
|
EFloat |
RoundToExponentExact(int exponentSmall,
EContext ctx)
Returns a binary float with the same value as this object but rounded to an
integer, and signals an inexact flag if the result would be inexact.
|
EFloat |
RoundToIntegerExact(EContext ctx)
Returns a binary float with the same value as this object but rounded to an
integer, and signals an inexact flag if the result would be inexact.
|
EFloat |
RoundToIntegerNoRoundedFlag(EContext ctx)
Returns a binary float with the same value as this object but rounded to an
integer, without adding the
FlagInexact or FlagRounded
flags. |
EFloat |
RoundToIntegralExact(EContext ctx)
Deprecated.
Renamed to RoundToIntegerExact.
|
EFloat |
RoundToIntegralNoRoundedFlag(EContext ctx)
Deprecated.
Renamed to RoundToIntegerNoRoundedFlag.
|
EFloat |
RoundToPrecision(EContext ctx)
Rounds this object's value to a given precision, using the given
rounding mode and range of exponent.
|
EFloat |
ScaleByPowerOfTwo(EInteger bigPlaces)
Returns a number similar to this number but with the scale adjusted.
|
EFloat |
ScaleByPowerOfTwo(EInteger bigPlaces,
EContext ctx)
Returns a number similar to this number but with its scale adjusted.
|
EFloat |
ScaleByPowerOfTwo(int places)
Returns a number similar to this number but with the scale adjusted.
|
EFloat |
ScaleByPowerOfTwo(int places,
EContext ctx)
Returns a number similar to this number but with the scale adjusted.
|
int |
signum()
Gets this value's sign: -1 if negative; 1 if positive; 0 if zero.
|
EFloat |
Sqrt(EContext ctx)
Finds the square root of this object's value.
|
EFloat |
SquareRoot(EContext ctx)
Deprecated.
Renamed to Sqrt.
|
EFloat |
Subtract(EFloat otherValue)
Subtracts an arbitrary-precision binary float from this instance and returns
the result.
|
EFloat |
Subtract(EFloat otherValue,
EContext ctx)
Subtracts an arbitrary-precision binary float from this instance.
|
byte |
ToByteChecked()
Converts this number's value to a byte (from 0 to 255) if it can fit in a
byte (from 0 to 255) after truncating to an integer.
|
byte |
ToByteIfExact()
Converts this number's value to a byte (from 0 to 255) if it can fit in a
byte (from 0 to 255) without rounding to a different numerical value.
|
byte |
ToByteUnchecked()
Truncates this number's value to an integer and returns the
least-significant bits of its two's-complement form as a byte (from 0
to 255).
|
double |
ToDouble()
Not documented yet.
|
EDecimal |
ToEDecimal()
Converts this value to an arbitrary-precision decimal number.
|
EInteger |
ToEInteger()
Converts this value to an arbitrary-precision integer.
|
EInteger |
ToEIntegerExact()
Deprecated.
Renamed to ToEIntegerIfExact.
|
EInteger |
ToEIntegerIfExact()
Converts this value to an arbitrary-precision integer, checking whether the
value contains a fractional part.
|
String |
ToEngineeringString()
Converts this value to an arbitrary-precision decimal number, then returns
the value of that decimal's ToEngineeringString method.
|
EDecimal |
ToExtendedDecimal()
Deprecated.
Renamed to ToEDecimal.
|
short |
ToInt16Checked()
Converts this number's value to a 16-bit signed integer if it can fit in a
16-bit signed integer after truncating to an integer.
|
short |
ToInt16IfExact()
Converts this number's value to a 16-bit signed integer if it can fit in a
16-bit signed integer without rounding to a different numerical
value.
|
short |
ToInt16Unchecked()
Truncates this number's value to an integer and returns the
least-significant bits of its two's-complement form as a 16-bit
signed integer.
|
int |
ToInt32Checked()
Converts this number's value to a 32-bit signed integer if it can fit in a
32-bit signed integer after truncating to an integer.
|
int |
ToInt32IfExact()
Converts this number's value to a 32-bit signed integer if it can fit in a
32-bit signed integer without rounding to a different numerical
value.
|
int |
ToInt32Unchecked()
Truncates this number's value to an integer and returns the
least-significant bits of its two's-complement form as a 32-bit
signed integer.
|
long |
ToInt64Checked()
Converts this number's value to a 64-bit signed integer if it can fit in a
64-bit signed integer after truncating to an integer.
|
long |
ToInt64IfExact()
Converts this number's value to a 64-bit signed integer if it can fit in a
64-bit signed integer without rounding to a different numerical
value.
|
long |
ToInt64Unchecked()
Truncates this number's value to an integer and returns the
least-significant bits of its two's-complement form as a 64-bit
signed integer.
|
String |
ToPlainString()
Converts this value to a string, but without exponential notation.
|
String |
ToShortestString(EContext ctx)
Returns a string representation of this number's value after rounding to the
given precision (using the given arithmetic context).
|
float |
ToSingle()
Converts this value to its closest equivalent as 32-bit floating-point
number.
|
String |
toString()
Converts this number's value to a text string.
|
EFloat |
Ulp()
Returns the unit in the last place.
|
public static final EFloat NaN
public static final EFloat NegativeInfinity
public static final EFloat NegativeZero
public static final EFloat One
public static final EFloat PositiveInfinity
public static final EFloat SignalingNaN
public static final EFloat Ten
public static final EFloat Zero
public final EInteger getExponent()
public final boolean isFinite()
true if this object is finite (not infinity or not-a-number
(NaN)); otherwise, false.public final boolean isNegative()
true if this object is negative, including negative zero;
otherwise, false.public final boolean isZero()
true if this object's value equals 0; otherwise, . false.public final EInteger getMantissa()
public final int signum()
public final EInteger getUnsignedMantissa()
public static EFloat Create(int mantissaSmall, int exponentSmall)
mantissaSmall - The parameter mantissaSmall is not documented
yet.exponentSmall - The parameter exponentSmall is not documented
yet.public static EFloat Create(EInteger mantissa, EInteger exponent)
mantissa - The parameter mantissa is not documented yet.exponent - The parameter exponent is not documented yet.NullPointerException - The parameter "mantissa (significand)"
or exponent is null.public static EFloat CreateNaN(EInteger diag)
diag - A number to use as diagnostic information associated with this
object. If none is needed, should be zero.NullPointerException - The parameter diag is null.IllegalArgumentException - The parameter diag is less than 0.public static EFloat CreateNaN(EInteger diag, boolean signaling, boolean negative, EContext ctx)
diag - A number to use as diagnostic information associated with this
object. If none is needed, should be zero.signaling - Whether the return value will be signaling (true) or quiet
(false).negative - Whether the return value is negative.ctx - An arithmetic context to control the precision (in bits) of the
diagnostic information. The rounding and exponent range of this
context will be ignored. Can be null. The only flag that can be
signaled in this context is FlagInvalid, which happens if diagnostic
information needs to be truncated and too much memory is required to
do so.NullPointerException - The parameter diag is null.IllegalArgumentException - The parameter diag is less than 0.public static EFloat FromDouble(double dbl)
dbl - A 64-bit floating-point number.dbl.public static EFloat FromEInteger(EInteger bigint)
bigint - An arbitrary-precision integer.public static EFloat FromSingle(float flt)
flt - A 32-bit floating-point number.flt.public static EFloat FromString(String str, int offset, int length, EContext ctx)
The format of the string generally consists of:
The string can also be "-INF", "-Infinity", "Infinity", "INF", quiet NaN ("NaN") followed by any number of digits, or signaling NaN ("sNaN") followed by any number of digits, all in any combination of upper and lower case.
All characters mentioned above are the corresponding characters in the Basic Latin range. In particular, the digits must be the basic digits 0 to 9 (U + 0030 to U + 0039). The string is not allowed to contain white space characters, including spaces.
str - A text string.offset - A zero-based index showing where the desired portion of str begins.length - The length, in code units, of the desired portion of str (but not more than str 's length).ctx - An EContext object specifying the precision, rounding, and
exponent range (in bits) to apply to the parsed number. Can be null.NullPointerException - The parameter str is null.IllegalArgumentException - Either offset or length is
less than 0 or greater than str 's length, or str ' s
length minus offset is less than length.public static EFloat FromString(String str)
str - The parameter str is not documented yet.public static EFloat FromString(String str, EContext ctx)
str - A text string.ctx - An EContext object specifying the precision, rounding, and
exponent range to apply to the parsed number. Can be null.NullPointerException - The parameter str is null.public static EFloat FromString(String str, int offset, int length)
FromString(String, int, int, EContext)
method.str - A text string.offset - A zero-based index showing where the desired portion of str begins.length - The length, in code units, of the desired portion of str (but not more than str 's length).NullPointerException - The parameter str is null.IllegalArgumentException - Either offset or length is
less than 0 or greater than str 's length, or str ' s
length minus offset is less than length.public static EFloat Max(EFloat first, EFloat second, EContext ctx)
first - The first value to compare.second - The second value to compare.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.public static EFloat Max(EFloat first, EFloat second)
first - An arbitrary-precision binary float.second - Another arbitrary-precision binary float.public static EFloat MaxMagnitude(EFloat first, EFloat second, EContext ctx)
first - The first value to compare.second - The second value to compare.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.public static EFloat MaxMagnitude(EFloat first, EFloat second)
first - The first value to compare.second - The second value to compare.public static EFloat Min(EFloat first, EFloat second, EContext ctx)
first - The first value to compare.second - The second value to compare.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.public static EFloat Min(EFloat first, EFloat second)
first - The first value to compare.second - The second value to compare.public static EFloat MinMagnitude(EFloat first, EFloat second, EContext ctx)
first - The first value to compare.second - The second value to compare.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.public static EFloat MinMagnitude(EFloat first, EFloat second)
first - The first value to compare.second - The second value to compare.public static EFloat PI(EContext ctx)
ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). This parameter
can't be null, as π can never be represented exactly..ctx is null
or the precision is unlimited (the context's Precision property is
0).public EFloat Abs()
public EFloat Abs(EContext context)
context - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and no rounding is needed.public EFloat Add(EFloat otherValue)
otherValue - An arbitrary-precision binary float.public EFloat Add(EFloat otherValue, EContext ctx)
otherValue - The number to add to.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and no rounding is needed.public int compareTo(EFloat other)
This method is not consistent with the Equals method because two different numbers with the same mathematical value, but different exponents, will compare as equal.
In this method, negative zero and positive zero are considered equal.
If this object or the other object is a quiet NaN or signaling NaN, this method will not trigger an error. Instead, NaN will compare greater than any other number, including infinity. Two different NaN values will be considered equal.
compareTo in interface Comparable<EFloat>other - An arbitrary-precision binary float.other is null, or 0 if both values are equal.public EFloat CompareToSignal(EFloat other, EContext ctx)
In this method, negative zero and positive zero are considered equal.
If this object or the other object is a quiet NaN or signaling NaN, this method will return a quiet NaN and will signal a FlagInvalid flag.
other - An arbitrary-precision binary float.ctx - An arithmetic context. The precision, rounding, and exponent
range are ignored. If HasFlags of the context is true, will
store the flags resulting from the operation (the flags are in
addition to the pre-existing flags). Can be null.public int CompareToTotal(EFloat other, EContext ctx)
other - An arbitrary-precision binary float to compare with this one.ctx - An arithmetic context. Flags will be set in this context only if
HasFlags and IsSimplified of the context are true and
only if an operand needed to be rounded before carrying out the
operation. Can be null.public int CompareToTotal(EFloat other)
other - An arbitrary-precision binary float to compare with this one.public int CompareToTotalMagnitude(EFloat other)
other - An arbitrary-precision binary float to compare with this one.public EFloat CompareToWithContext(EFloat other, EContext ctx)
In this method, negative zero and positive zero are considered equal.
If this object or the other object is a quiet NaN or signaling NaN, this method returns a quiet NaN, and will signal a FlagInvalid flag if either is a signaling NaN.
other - An arbitrary-precision binary float.ctx - An arithmetic context. The precision, rounding, and exponent
range are ignored. If HasFlags of the context is true, will
store the flags resulting from the operation (the flags are in
addition to the pre-existing flags). Can be null.public EFloat CopySign(EFloat other)
other - A number whose sign will be copied.NullPointerException - The parameter other is null.public EFloat Divide(EFloat divisor)
divisor - An arbitrary-precision binary float to divide by.public EFloat Divide(EFloat divisor, EContext ctx)
divisor - An arbitrary-precision binary float to divide by.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and no rounding is needed.ctx is null or ctx 's
precision is 0, and the result would have a nonterminating binary
expansion; or, the rounding mode is ERounding.None and the result is
not exact.@Deprecated public EFloat[] DivideAndRemainderNaturalScale(EFloat divisor)
divisor - An arbitrary-precision binary float to divide by.@Deprecated public EFloat[] DivideAndRemainderNaturalScale(EFloat divisor, EContext ctx)
divisor - An arbitrary-precision binary float to divide by.ctx - An arithmetic context object to control the precision, rounding,
and exponent range of the result. This context will be used only in
the division portion of the remainder calculation; as a result, it's
possible for the remainder to have a higher precision than given in
this context. Flags will be set on the given context only if the
context's HasFlags is true and the integer part of the
division result doesn't fit the precision and exponent range without
rounding. Can be null, in which the precision is unlimited and no
additional rounding, other than the rounding down to an integer after
division, is needed.public EFloat DivideToExponent(EFloat divisor, long desiredExponentSmall, EContext ctx)
divisor - An arbitrary-precision binary float to divide by.desiredExponentSmall - The desired exponent. A negative number places
the cutoff point to the right of the usual radix point (so a negative
number means the number of binary digit places to round to). A
positive number places the cutoff point to the left of the usual
radix point.ctx - An arithmetic context object to control the rounding mode to use
if the result must be scaled down to have the same exponent as this
value. If the precision given in the context is other than 0, calls
the Quantize method with both arguments equal to the result of the
operation (and can signal FlagInvalid and return NaN if the result
doesn't fit the given precision). If HasFlags of the context
is true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the default rounding mode is HalfEven.public EFloat DivideToExponent(EFloat divisor, long desiredExponentSmall, ERounding rounding)
divisor - An arbitrary-precision binary float to divide by.desiredExponentSmall - The desired exponent. A negative number places
the cutoff point to the right of the usual radix point (so a negative
number means the number of binary digit places to round to). A
positive number places the cutoff point to the left of the usual
radix point.rounding - The rounding mode to use if the result must be scaled down
to have the same exponent as this value.public EFloat DivideToExponent(EFloat divisor, EInteger exponent, EContext ctx)
divisor - An arbitrary-precision binary float to divide by.exponent - The desired exponent. A negative number places the cutoff
point to the right of the usual radix point (so a negative number
means the number of binary digit places to round to). A positive
number places the cutoff point to the left of the usual radix point.ctx - An arithmetic context object to control the rounding mode to use
if the result must be scaled down to have the same exponent as this
value. If the precision given in the context is other than 0, calls
the Quantize method with both arguments equal to the result of the
operation (and can signal FlagInvalid and return NaN if the result
doesn't fit the given precision). If HasFlags of the context
is true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the default rounding mode is HalfEven.public EFloat DivideToExponent(EFloat divisor, EInteger desiredExponent, ERounding rounding)
divisor - An arbitrary-precision binary float to divide by.desiredExponent - The desired exponent. A negative number places the
cutoff point to the right of the usual radix point (so a negative
number means the number of binary digit places to round to). A
positive number places the cutoff point to the left of the usual
radix point.rounding - The rounding mode to use if the result must be scaled down
to have the same exponent as this value.public EFloat DivideToIntegerNaturalScale(EFloat divisor)
divisor - An arbitrary-precision binary float to divide by.public EFloat DivideToIntegerNaturalScale(EFloat divisor, EContext ctx)
divisor - The number to divide by.ctx - An arithmetic context object to control the precision, rounding,
and exponent range of the integer part of the result. Flags will be
set on the given context only if the context's HasFlags is
true and the integer part of the result doesn't fit the precision and
exponent range without rounding. Can be null, in which the precision
is unlimited and no additional rounding, other than the rounding down
to an integer after division, is needed.public EFloat DivideToIntegerZeroScale(EFloat divisor, EContext ctx)
divisor - The number to divide by.ctx - An arithmetic context object to control the precision. The
rounding and exponent range settings of this context are ignored. If
HasFlags of the context is true, will also store the flags
resulting from the operation (the flags are in addition to the
pre-existing flags). Can be null, in which case the precision is
unlimited.public EFloat DivideToSameExponent(EFloat divisor, ERounding rounding)
divisor - The number to divide by.rounding - The rounding mode to use if the result must be scaled down
to have the same exponent as this value.public EFloat[] DivRemNaturalScale(EFloat divisor)
divisor - An arbitrary-precision binary float to divide by.public EFloat[] DivRemNaturalScale(EFloat divisor, EContext ctx)
divisor - An arbitrary-precision binary float to divide by.ctx - An arithmetic context object to control the precision, rounding,
and exponent range of the result. This context will be used only in
the division portion of the remainder calculation; as a result, it's
possible for the remainder to have a higher precision than given in
this context. Flags will be set on the given context only if the
context's HasFlags is true and the integer part of the
division result doesn't fit the precision and exponent range without
rounding. Can be null, in which the precision is unlimited and no
additional rounding, other than the rounding down to an integer after
division, is needed.public boolean equals(EFloat other)
other - An arbitrary-precision binary float.true if this object's mantissa (significand) and exponent
are equal to those of another object; otherwise, false.public boolean equals(Object obj)
public boolean EqualsInternal(EFloat otherValue)
otherValue - An arbitrary-precision binary float.true if this object's mantissa (significand) and exponent
are equal to those of another object; otherwise, false.public EFloat Exp(EContext ctx)
ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). This parameter
can't be null, as the exponential function's results are generally
not exact. (Unlike in the General Binary Arithmetic
Specification, any rounding mode is allowed.).ctx is null
or the precision is unlimited (the context's Precision property is
0).public int hashCode()
public boolean IsInfinity()
true if this object is positive or negative infinity;
otherwise, false.public boolean IsNaN()
true if this object is not a number (NaN); otherwise, false.public boolean IsNegativeInfinity()
true if this object is negative infinity; otherwise, false.public boolean IsPositiveInfinity()
true if this object is positive infinity; otherwise, false.public boolean IsQuietNaN()
true if this object is a quiet not-a-number value;
otherwise, false.public boolean IsSignalingNaN()
true if this object is a signaling not-a-number value;
otherwise, false.public EFloat Log(EContext ctx)
ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). This parameter
can't be null, as the ln function's results are generally not
exact. (Unlike in the General Binary Arithmetic Specification,
any rounding mode is allowed.).ctx is null or the precision is unlimited (the context's
Precision property is 0). Signals no flags and returns negative
infinity if this object's value is 0.public EFloat Log10(EContext ctx)
ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). This parameter
can't be null, as the ln function's results are generally not
exact. (Unlike in the General Binary Arithmetic Specification,
any rounding mode is allowed.).ctx is null
or the precision is unlimited (the context's Precision property is
0).public EFloat MovePointLeft(int places)
places - The number of binary digit places to move the radix point to
the left. If this number is negative, instead moves the radix point
to the right by this number's absolute value.places, but not to
more than 0.public EFloat MovePointLeft(int places, EContext ctx)
places - The number of binary digit places to move the radix point to
the left. If this number is negative, instead moves the radix point
to the right by this number's absolute value.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.places, but not to
more than 0.public EFloat MovePointLeft(EInteger bigPlaces)
bigPlaces - The number of binary digit places to move the radix point
to the left. If this number is negative, instead moves the radix
point to the right by this number's absolute value.bigPlaces, but not
to more than 0.public EFloat MovePointLeft(EInteger bigPlaces, EContext ctx)
bigPlaces - The number of binary digit places to move the radix point
to the left. If this number is negative, instead moves the radix
point to the right by this number's absolute value.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.bigPlaces, but not
to more than 0.public EFloat MovePointRight(int places)
places - The number of binary digit places to move the radix point to
the right. If this number is negative, instead moves the radix point
to the left by this number's absolute value.places, but not to
more than 0.public EFloat MovePointRight(int places, EContext ctx)
places - The number of binary digit places to move the radix point to
the right. If this number is negative, instead moves the radix point
to the left by this number's absolute value.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.places, but not to
more than 0.public EFloat MovePointRight(EInteger bigPlaces)
bigPlaces - The number of binary digit places to move the radix point
to the right. If this number is negative, instead moves the radix
point to the left by this number's absolute value.bigPlaces, but not
to more than 0.public EFloat MovePointRight(EInteger bigPlaces, EContext ctx)
bigPlaces - The number of binary digit places to move the radix point
to the right. If this number is negative, instead moves the radix
point to the left by this number's absolute value.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.bigPlaces, but not
to more than 0.public EFloat Multiply(EFloat otherValue)
otherValue - Another binary float.public EFloat Multiply(EFloat op, EContext ctx)
op - Another binary float.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.public EFloat MultiplyAndAdd(EFloat multiplicand, EFloat augend)
multiplicand - The value to multiply.augend - The value to add.multiplicand + augend.public EFloat MultiplyAndAdd(EFloat op, EFloat augend, EContext ctx)
op - The value to multiply.augend - The value to add.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed. If
the precision doesn't indicate a simplified arithmetic, rounding and
precision/exponent adjustment is done only once, namely, after
multiplying and adding.public EFloat MultiplyAndSubtract(EFloat op, EFloat subtrahend, EContext ctx)
op - The value to multiply.subtrahend - The value to subtract.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed. If
the precision doesn't indicate a simplified arithmetic, rounding and
precision/exponent adjustment is done only once, namely, after
multiplying and subtracting.NullPointerException - The parameter op or subtrahend is null.public EFloat Negate()
public EFloat Negate(EContext context)
context - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.public EFloat NextMinus(EContext ctx)
ctx - An arithmetic context object to control the precision and
exponent range of the result. The rounding mode from this context is
ignored. If HasFlags of the context is true, will also store
the flags resulting from the operation (the flags are in addition to
the pre-existing flags).ctx is null, the precision is 0, or ctx has an unlimited
exponent range.public EFloat NextPlus(EContext ctx)
ctx - An arithmetic context object to control the precision and
exponent range of the result. The rounding mode from this context is
ignored. If HasFlags of the context is true, will also store
the flags resulting from the operation (the flags are in addition to
the pre-existing flags).ctx is null, the precision is 0, or ctx has
an unlimited exponent range.public EFloat NextToward(EFloat otherValue, EContext ctx)
otherValue - An arbitrary-precision binary float that the return value
will approach.ctx - An arithmetic context object to control the precision and
exponent range of the result. The rounding mode from this context is
ignored. If HasFlags of the context is true, will also store
the flags resulting from the operation (the flags are in addition to
the pre-existing flags).ctx is null, the precision is 0, or ctx has
an unlimited exponent range.public EFloat Plus(EContext ctx)
ctx - A context for controlling the precision, rounding mode, and
exponent range. Can be null, in which case the precision is unlimited
and rounding isn't needed.ctx is
null or the precision and exponent range are unlimited.public EFloat Pow(EFloat exponent, EContext ctx)
exponent - An arbitrary-precision binary float expressing the exponent
to raise this object's value to.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.ctx is null or the precision is unlimited (the context's Precision
property is 0), and the exponent has a fractional part.public EFloat Pow(int exponentSmall, EContext ctx)
exponentSmall - The exponent to raise this object's value to.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.public EFloat Pow(int exponentSmall)
exponentSmall - The exponent to raise this object's value to.public EInteger Precision()
public EFloat Quantize(EInteger desiredExponent, EContext ctx)
Note that this is not always the same as rounding to a given number of binary digit places, since it can fail if the difference between this value's exponent and the desired exponent is too big, depending on the maximum precision. If rounding to a number of binary digit places is desired, it's better to use the RoundToExponent and RoundToIntegral methods instead.
Remark: This method can be used to implement fixed-point binary arithmetic, in which each binary float has a fixed number of digits after the radix point. The following code example returns a fixed-point number with up to 20 digits before and exactly 5 digits after the radix point:
// After performing arithmetic operations, adjust // the number to 5
digits after the radix point number = number.Quantize(
EInteger.FromInt32(-5), // five digits after the radix point
EContext.ForPrecision(25) // 25-digit precision); A fixed-point binary arithmetic in which no digits come after the radix point (a desired exponent of 0) is considered an "integer arithmetic".
desiredExponent - The desired exponent for the result. The exponent is
the number of fractional digits in the result, expressed as a
negative number. Can also be positive, which eliminates lower-order
places from the number. For example, -3 means round to the sixteenth
(10b^-3, 0.0001b), and 3 means round to the sixteen-place (10b^3,
1000b). A value of 0 rounds the number to an integer.ctx - An arithmetic context to control precision and rounding of the
result. If HasFlags of the context is true, will also store
the flags resulting from the operation (the flags are in addition to
the pre-existing flags). Can be null, in which case the default
rounding mode is HalfEven.public EFloat Quantize(int desiredExponentInt, EContext ctx)
Note that this is not always the same as rounding to a given number of binary digit places, since it can fail if the difference between this value's exponent and the desired exponent is too big, depending on the maximum precision. If rounding to a number of binary digit places is desired, it's better to use the RoundToExponent and RoundToIntegral methods instead.
Remark: This method can be used to implement fixed-point binary arithmetic, in which each binary float has a fixed number of digits after the radix point. The following code example returns a fixed-point number with up to 20 digits before and exactly 5 digits after the radix point:
// After performing arithmetic operations, adjust // the number to 5
digits after the radix point number = number.Quantize(-5, // five
digits after the radix point EContext.ForPrecision(25) // 25-digit
precision); A fixed-point binary arithmetic in which no digits come after the radix point (a desired exponent of 0) is considered an "integer arithmetic".
desiredExponentInt - The desired exponent for the result. The exponent
is the number of fractional digits in the result, expressed as a
negative number. Can also be positive, which eliminates lower-order
places from the number. For example, -3 means round to the sixteenth
(10b^-3, 0.0001b), and 3 means round to the sixteen-place (10b^3,
1000b). A value of 0 rounds the number to an integer.ctx - An arithmetic context to control precision and rounding of the
result. If HasFlags of the context is true, will also store
the flags resulting from the operation (the flags are in addition to
the pre-existing flags). Can be null, in which case the default
rounding mode is HalfEven.public EFloat Quantize(EFloat otherValue, EContext ctx)
Note that this is not always the same as rounding to a given number of binary digit places, since it can fail if the difference between this value's exponent and the desired exponent is too big, depending on the maximum precision. If rounding to a number of binary digit places is desired, it's better to use the RoundToExponent and RoundToIntegral methods instead.
Remark: This method can be used to implement fixed-point binary arithmetic, in which a fixed number of digits come after the radix point. A fixed-point binary arithmetic in which no digits come after the radix point (a desired exponent of 0) is considered an "integer arithmetic".
otherValue - A binary float containing the desired exponent of the
result. The mantissa (significand) is ignored. The exponent is the
number of fractional digits in the result, expressed as a negative
number. Can also be positive, which eliminates lower-order places
from the number. For example, -3 means round to the sixteenth
(10b^-3, 0.0001b), and 3 means round to the sixteen-place (10b^3,
1000b). A value of 0 rounds the number to an integer.ctx - An arithmetic context to control precision and rounding of the
result. If HasFlags of the context is true, will also store
the flags resulting from the operation (the flags are in addition to
the pre-existing flags). Can be null, in which case the default
rounding mode is HalfEven.public EFloat Reduce(EContext ctx)
If this object's value is 0, changes the exponent to 0.
ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and rounding isn't needed.public EFloat Remainder(EFloat divisor, EContext ctx)
divisor - The number to divide by.ctx - An arithmetic context object to control the precision, rounding,
and exponent range of the result. This context will be used both in
the division portion and in the remainder portion of the remainder
calculation. If HasFlags of the context is true, will also
store the flags resulting from the operation (the flags are in
addition to the pre-existing flags). Can be null, in which case the
precision is unlimited and no additional rounding (other than the
rounding from integer division) is needed.public EFloat RemainderNaturalScale(EFloat divisor)
"this" - (("this" /
"divisor") * "divisor")divisor - The number to divide by.public EFloat RemainderNaturalScale(EFloat divisor, EContext ctx)
divisor - The number to divide by.ctx - An arithmetic context object to control the precision, rounding,
and exponent range of the result. This context will be used only in
the division portion of the remainder calculation; as a result, it's
possible for the return value to have a higher precision than given
in this context. Flags will be set on the given context only if the
context's HasFlags is true and the integer part of the
division result doesn't fit the precision and exponent range without
rounding. Can be null, in which the precision is unlimited and no
additional rounding, other than the rounding down to an integer after
division, is needed.public EFloat RemainderNear(EFloat divisor, EContext ctx)
divisor - The number to divide by.ctx - An arithmetic context object to control the precision. The
rounding and exponent range settings of this context are ignored (the
rounding mode is always treated as HalfEven). If HasFlags of
the context is true, will also store the flags resulting from the
operation (the flags are in addition to the pre-existing flags). Can
be null, in which the precision is unlimited.public EFloat RoundToExponent(EInteger exponent, EContext ctx)
exponent - The minimum exponent the result can have. This is the
maximum number of fractional digits in the result, expressed as a
negative number. Can also be positive, which eliminates lower-order
places from the number. For example, -3 means round to the sixteenth
(10b^-3, 0.0001b), and 3 means round to the sixteen-place (10b^3,
1000b). A value of 0 rounds the number to an integer.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the default rounding mode is HalfEven.public EFloat RoundToExponent(int exponentSmall, EContext ctx)
exponentSmall - The minimum exponent the result can have. This is the
maximum number of fractional digits in the result, expressed as a
negative number. Can also be positive, which eliminates lower-order
places from the number. For example, -3 means round to the sixteenth
(10b^-3, 0.0001b), and 3 means round to the sixteen-place (10b^3,
1000b). A value of 0 rounds the number to an integer.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the default rounding mode is HalfEven.public EFloat RoundToExponentExact(EInteger exponent, EContext ctx)
exponent - The minimum exponent the result can have. This is the
maximum number of fractional digits in the result, expressed as a
negative number. Can also be positive, which eliminates lower-order
places from the number. For example, -3 means round to the sixteenth
(10b^-3, 0.0001b), and 3 means round to the sixteen-place (10b^3,
1000b). A value of 0 rounds the number to an integer.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the default rounding mode is HalfEven.public EFloat RoundToExponentExact(EInteger exponent, ERounding rounding)
exponent - An arbitrary-precision integer.rounding - An ERounding object.public EFloat RoundToExponentExact(int exponentSmall, EContext ctx)
exponentSmall - The minimum exponent the result can have. This is the
maximum number of fractional digits in the result, expressed as a
negative number. Can also be positive, which eliminates lower-order
places from the number. For example, -3 means round to the sixteenth
(10b^-3, 0.0001b), and 3 means round to the sixteen-place (10b^3,
1000b). A value of 0 rounds the number to an integer.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the default rounding mode is HalfEven.public EFloat RoundToIntegerExact(EContext ctx)
ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the default rounding mode is HalfEven.public EFloat RoundToIntegerNoRoundedFlag(EContext ctx)
FlagInexact or FlagRounded
flags.ctx - An arithmetic context to control precision and rounding of the
result. If HasFlags of the context is true, will also store
the flags resulting from the operation (the flags are in addition to
the pre-existing flags), except that this function will never add the
FlagRounded and FlagInexact flags (the only
difference between this and RoundToExponentExact). Can be null, in
which case the default rounding mode is HalfEven.@Deprecated public EFloat RoundToIntegralExact(EContext ctx)
ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the default rounding mode is HalfEven.@Deprecated public EFloat RoundToIntegralNoRoundedFlag(EContext ctx)
FlagInexact or FlagRounded
flags.ctx - An arithmetic context to control precision and rounding of the
result. If HasFlags of the context is true, will also store
the flags resulting from the operation (the flags are in addition to
the pre-existing flags), except that this function will never add the
FlagRounded and FlagInexact flags (the only
difference between this and RoundToExponentExact). Can be null, in
which case the default rounding mode is HalfEven.public EFloat RoundToPrecision(EContext ctx)
ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and no rounding is needed.ctx is
null or the precision and exponent range are unlimited.public EFloat ScaleByPowerOfTwo(int places)
places - A 32-bit signed integer.public EFloat ScaleByPowerOfTwo(int places, EContext ctx)
places - A 32-bit signed integer.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null.public EFloat ScaleByPowerOfTwo(EInteger bigPlaces)
bigPlaces - An arbitrary-precision integer.bigPlaces.public EFloat ScaleByPowerOfTwo(EInteger bigPlaces, EContext ctx)
bigPlaces - An arbitrary-precision integer.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null.bigPlaces.public EFloat Sqrt(EContext ctx)
ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). This parameter
can't be null, as the square root function's results are generally
not exact for many inputs. (Unlike in the General Binary
Arithmetic Specification, any rounding mode is allowed.).ctx is null or
the precision is unlimited (the context's Precision property is 0).@Deprecated public EFloat SquareRoot(EContext ctx)
ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). This parameter
can't be null, as the square root function's results are generally
not exact for many inputs. (Unlike in the General Binary
Arithmetic Specification, any rounding mode is allowed.).ctx is null or
the precision is unlimited (the context's Precision property is 0).public EFloat Subtract(EFloat otherValue)
otherValue - The number to subtract from this instance's value.public EFloat Subtract(EFloat otherValue, EContext ctx)
otherValue - The number to subtract from this instance's value.ctx - An arithmetic context to control precision, rounding, and
exponent range of the result. If HasFlags of the context is
true, will also store the flags resulting from the operation (the
flags are in addition to the pre-existing flags). Can be null, in
which case the precision is unlimited and no rounding is needed.NullPointerException - The parameter otherValue is
null.public double ToDouble()
public EDecimal ToEDecimal()
public EInteger ToEInteger()
ArithmeticException - This object's value is infinity or
not-a-number (NaN).@Deprecated public EInteger ToEIntegerExact()
ArithmeticException - This object's value is infinity or
not-a-number (NaN).ArithmeticException - This object's value is not an exact integer.public EInteger ToEIntegerIfExact()
ArithmeticException - This object's value is infinity or
not-a-number (NaN).ArithmeticException - This object's value is not an exact integer.public String ToEngineeringString()
@Deprecated public EDecimal ToExtendedDecimal()
public String ToPlainString()
public String ToShortestString(EContext ctx)
ctx - An arithmetic context to control precision (in bits), rounding,
and exponent range of the rounded number. If HasFlags of the
context is true, will also store the flags resulting from the
operation (the flags are in addition to the pre-existing flags). Can
be null. If this parameter is null or defines no maximum precision,
returns the same value as the toString() method.public float ToSingle()
If this value is a NaN, sets the high bit of the 32-bit floating point number's significand area for a quiet NaN, and clears it for a signaling NaN. Then the other bits of the significand area are set to the lowest bits of this object's unsigned mantissa (significand), and the next-highest bit of the significand area is set if those bits are all zeros and this is a signaling NaN. Unfortunately, in the .NET implementation, the return value of this method may be a quiet NaN even if a signaling NaN would otherwise be generated.
public String toString()
toString in class Objectpublic EFloat Ulp()
public byte ToByteChecked()
ArithmeticException - This value is infinity or not-a-number, or
the truncated integer is less than 0 or greater than 255.public byte ToByteUnchecked()
public byte ToByteIfExact()
ArithmeticException - This value is infinity or not-a-number, is not
an exact integer, or is less than 0 or greater than 255.public static EFloat FromByte(byte inputByte)
inputByte - The number to convert as a byte (from 0 to 255).public short ToInt16Checked()
ArithmeticException - This value is infinity or not-a-number, or
the truncated integer is less than -32768 or greater than 32767.public short ToInt16Unchecked()
public short ToInt16IfExact()
ArithmeticException - This value is infinity or not-a-number, is not
an exact integer, or is less than -32768 or greater than 32767.public static EFloat FromInt16(short inputInt16)
inputInt16 - The number to convert as a 16-bit signed integer.public int ToInt32Checked()
ArithmeticException - This value is infinity or not-a-number, or
the truncated integer is less than -2147483648 or greater than
2147483647.public int ToInt32Unchecked()
public int ToInt32IfExact()
ArithmeticException - This value is infinity or not-a-number, is not
an exact integer, or is less than -2147483648 or greater than
2147483647.public static EFloat FromInt32(int inputInt32)
inputInt32 - The number to convert as a 32-bit signed integer.public long ToInt64Checked()
ArithmeticException - This value is infinity or not-a-number, or
the truncated integer is less than -9223372036854775808 or greater
than 9223372036854775807.public long ToInt64Unchecked()
public long ToInt64IfExact()
ArithmeticException - This value is infinity or not-a-number, is not
an exact integer, or is less than -9223372036854775808 or greater
than 9223372036854775807.public static EFloat FromInt64(long inputInt64)
inputInt64 - The number to convert as a 64-bit signed integer.CBOR for Java documentation, generated in 2016.