Class ExtendedReal

java.lang.Object
java.lang.Number
org.monte.media.math.ExtendedReal
All Implemented Interfaces:
Serializable

public class ExtendedReal extends 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.
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Goldau, Switzerland.
See Also:
  • Field Details

  • Constructor Details

    • ExtendedReal

      public ExtendedReal(byte[] bits)
    • ExtendedReal

      public ExtendedReal(double d)
  • Method Details

    • toByteArray

      public byte[] toByteArray()
    • isNaN

      public boolean isNaN()
    • isInfinite

      public boolean isInfinite()
    • doubleValue

      public double doubleValue()
      Specified by:
      doubleValue in class Number
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public boolean equals(ExtendedReal obj)
    • toString

      public String toString()
      FIXME: Loss of precision, because we currently convert to double before we create the String.
      Overrides:
      toString in class Object