All Packages  This Package  Class Hierarchy  Class Search  Index

Class bmsi.edx.S1Float
java.lang.Object
   |
   +----bmsi.edx.S1Float

  Summary

public class  S1Float
     extends java.lang.Object
{
          // Fields 2
     public static final long MAX_EXT;
     public static final int MAX_FLOAT;

          // Constructors 1
     public S1Float();

          // Methods 4
     public static long doubleToS1ExtBits(double);
     public static int doubleToS1FloatBits(double);
     public static double s1ExtBitsToDouble(long);
     public static double s1FloatBitsToDouble(int);

}

Conversions between Series/1 floating-point format and Java. Series/1 format is slightly wierd. There's a sign bit where you'd expect it to be, a 7-bit exponent (which they call a "characteristic"), and a 24-bit fraction. The wierd part is that the exponent is base 16, a sneaky way of extending the range of their numbers in exchange for a sort of statistical loss of precision. Normalization on the Series/1 just means making sure that the top four bits of the fraction -- the top hex "digit" if you will -- are non-zero; therefore there may be as many as three zero bits at the top of the fraction, which are wasted if you're thinking in base-2 terms. Then again, there may not.

Note that there's a bit of lost precision when we convert back to Series/1 format after an operation. At the moment we're not rounding, we're just dropping the bottom end of the IEEE fraction into the bit bucket. Hope nobody notices.

Pnuts test script:

f = class bmsi.edx.S1Float
a = [ 0.5, 25.0, Double::POSITIVE_INFINITY, Math::PI, -0.25 ]
a = a + [ -0.1, Double::NEGATIVE_INFINITY, -1234567890.1 ]
foreach d (double[0] + a) {
  dw = f::doubleToS1FloatBits(d)
  System::err.print("" + d + " -> " + Integer::toHexString(dw))
  System::err.println(" -> " + f::s1FloatBitsToDouble(dw))
  lw = f::doubleToS1ExtBits(d)
  System::err.print("" + d + " -> " + Long::toHexString(lw))
  System::err.println(" -> " + f::s1ExtBitsToDouble(lw))
}
Results:
0.5 -> 40800000 -> 0.5
0.5 -> 4080000000000000 -> 0.5
25.0 -> 42190000 -> 25.0
25.0 -> 4219000000000000 -> 25.0
Infinity -> 7fffffff -> Infinity
Infinity -> 7fffffffffffffff -> Infinity
3.141592653589793 -> 413243f6 -> 3.141592025756836
3.141592653589793 -> 413243f6a8885a30 -> 3.141592653589793
-0.25 -> c0400000 -> -0.25
-0.25 -> c040000000000000 -> -0.25
-0.1 -> c0199999 -> -0.09999996423721313
-0.1 -> c01999999999999a -> -0.1
-Infinity -> ffffffff -> -Infinity
-Infinity -> ffffffffffffffff -> -Infinity
-1.2345678901E9 -> c8499602 -> -1.23456768E9
-1.2345678901E9 -> c8499602d2199998 -> -1.2345678901E9

Author:
Stuart D. Gathman Converted from the float.c module of EDX/MAX.




  Fields

· MAX_FLOAT

Summary  |  Top

   public static final int MAX_FLOAT


· MAX_EXT

Summary  |  Top
   public static final long MAX_EXT


  Constructors

· S1Float

Summary  |  Top

   public S1Float() 

Default constructor



  Methods

· s1FloatBitsToDouble

Summary  |  Top
   public static double s1FloatBitsToDouble(int s1f) 

Convert Series/1 floating point bits to a double. The result is a double to preserve the larger range of the S/1 format.



· s1ExtBitsToDouble

Summary  |  Top
   public static double s1ExtBitsToDouble(long s1x) 

Convert Series/1 extended floating point bits to a double. The result is a double to preserve the larger range of the S/1 format.



· doubleToS1FloatBits

Summary  |  Top
   public static int doubleToS1FloatBits(double f) 

Convert a double to Series/1 floating point bits.



· doubleToS1ExtBits

Summary  |  Top
   public static long doubleToS1ExtBits(double f) 

Convert a double to Series/1 extended format.



All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7