Copyright 2011-01-06 Werner Randelshofer

ch.randelshofer.util
Class ExtendedReal

java.lang.Object
  extended by java.lang.Number
      extended by 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

Field Summary
static ExtendedReal MAX_VALUE
           
static ExtendedReal MIN_VALUE
           
static ExtendedReal NaN
           
static ExtendedReal NEGATIVE_INFINITY
           
static ExtendedReal POSITIVE_INFINITY
           
 
Constructor Summary
ExtendedReal(byte[] bits)
           
ExtendedReal(double d)
           
 
Method Summary
 double doubleValue()
           
 boolean equals(ExtendedReal obj)
           
 boolean equals(java.lang.Object obj)
           
 float floatValue()
           
 int hashCode()
           
 int intValue()
           
 boolean isInfinite()
           
 boolean isNaN()
           
 long longValue()
           
 java.lang.String toString()
          FIXME: Loss of precision, because we currently convert to double before we create the String.
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

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
Constructor Detail

ExtendedReal

public ExtendedReal(byte[] bits)

ExtendedReal

public ExtendedReal(double d)
Method Detail

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

Copyright 2011-01-06 Werner Randelshofer