ch.randelshofer.util
Class ExtendedReal
java.lang.Object
java.lang.Number
ch.randelshofer.util.ExtendedReal
- All Implemented Interfaces:
- java.io.Serializable
public class ExtendedReal
- extends java.lang.Number
Represents an extended-real number as specified by IEEE 754.
An extended-real number uses 80 bits to represent a floating point
number. It is able to represent numbers ranging from 3.37*10^-4932
up to 1.18*10^4932.
Bit layout
79 78-64 63 62-0
Sign Biased Exponent Integer Fraction
For the single-real and double-real formats, only the fraction part
of the significand is encoded. The integer is assumed to be 1 for
all numbers except 0 and denormalized finite numbers. For the
extended-real format, the integer is contained in bit 64, and the
most significant fraction bit is bit 62. Here, the integer is
explicitly set to 1 for normalized numbers, infinites, and NaNs,
and to 0 for zero and denormalized numbers.
The exponent is encoded in biased format. The biasing constant is
16'383 for the extended-real format.
NaN Encodings for ExtendedReal:
Class Sign Biased Significand
Exponent Integer Fraction
------------------------------------------------------------
Positive +Infinity 0 11..11 1 00..00
+Normals 0 11..10 1 11..11
. . . .
. . . .
0 00..01 1 00..00
+Denormals 0 00..00 0 11..11
. . . .
. . . .
0 00..00 0 00..01
+Zero 0 00..00 0 00..00
Negative -Zero 1 00..00 0 00..00
-Denormals 1 00..00 0 00..01
. . . .
. . . .
1 00..00 0 11..11
-Normals 1 00..01 1 00..01
. . . .
. . . .
1 11..10 1 11..11
-Infinity 1 11..11 1 00..00
NaNs SNaN X 11..11 1 0X..XX(2
QNaN X 11..11 1 1X..XX
Real Indefinite 1 11..11 1 10..00
(2 The fraction for SNaN encodings must be non zero.
- Version:
- 0.1 2000-10-06 Conversions from bit array, and to double only.
- Author:
- Werner Randelshofer, Hausmatt 10, CH-6405 Immensee, Switzerland.
- See Also:
- Serialized Form
| Methods inherited from class java.lang.Number |
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
MAX_VALUE
public static final ExtendedReal MAX_VALUE
MIN_VALUE
public static final ExtendedReal MIN_VALUE
NaN
public static final ExtendedReal NaN
NEGATIVE_INFINITY
public static final ExtendedReal NEGATIVE_INFINITY
POSITIVE_INFINITY
public static final ExtendedReal POSITIVE_INFINITY
ExtendedReal
public ExtendedReal(byte[] bits)
ExtendedReal
public ExtendedReal(double d)
isNaN
public boolean isNaN()
isInfinite
public boolean isInfinite()
doubleValue
public double doubleValue()
- Specified by:
doubleValue in class java.lang.Number
floatValue
public float floatValue()
- Specified by:
floatValue in class java.lang.Number
intValue
public int intValue()
- Specified by:
intValue in class java.lang.Number
longValue
public long longValue()
- Specified by:
longValue in class java.lang.Number
hashCode
public int hashCode()
- Overrides:
hashCode in class java.lang.Object
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals in class java.lang.Object
equals
public boolean equals(ExtendedReal obj)
toString
public java.lang.String toString()
- FIXME: Loss of precision, because we currently convert to double before
we create the String.
- Overrides:
toString in class java.lang.Object