Draft 01/30/01

com.ibm.converters
Class FloatingPoint

java.lang.Object
  |
  +--com.ibm.converters.FloatingPoint

public class FloatingPoint
extends Object

Converters from floating point bytes to Java float, double, or java.math.BigDecimal.

Author:
Specification: Paul Ostler, John Vonau; Implementation: Sandy Pickering, Christine Casey, Mike Fulton

Field Summary
static int HEXADECIMAL_FLOATING_POINT
          Supported System/390 hexadecimal floating point representation.
static int IEEE_754_FLOATING_POINT
          Supported AS/400, Unix Big Endian IEEE 754 floating point representation.
static int IEEE_754_FLOATING_POINT_BYTE_REVERSED
          Supported Intel 80/86 Little Endian IEEE 754 floating point representation.
static int VAX_BINARY_FLOATING_POINT
          Placeholder for future support of VAX floating point representation.
 
Method Summary
static BigDecimal getBigDecimal(byte[] buffer, int offset, int representation)
          Build a java.math.BigDecimal from a 16-byte floating point representation.
static double getDouble(byte[] buffer, int offset, int representation)
          Build a Java double from an 8-byte floating point representation.
static float getFloat(byte[] buffer, int offset, int representation)
          Build a Java float from a 4-byte floating point representation.
static BigDecimal hexadecimalBytesToBigDecimal(byte[] buffer, int offset)
          Build a Java BigDecimal from a 16-byte hexadecimal floating point representation.
static double hexadecimalBytesToDouble(byte[] buffer, int offset)
          Build a Java double from an 8-byte hexadecimal floating point representation.
static float hexadecimalBytesToFloat(byte[] buffer, int offset)
          Build a Java float from a 4-byte hexadecimal floating point representation.
static BigDecimal ieee754BytesToBigDecimal(byte[] buffer, int offset)
          Build a Java BigDecimal from a 16-byte IEEE 754 floating point representation.
static double ieee754BytesToDouble(byte[] buffer, int offset)
          Build a Java double from an 8-byte IEEE 754 floating point representation.
static float ieee754BytesToFloat(byte[] buffer, int offset)
          Build a Java float from a 4-byte IEEE 754 floating point representation.
static BigDecimal ieee754ReversedBytesToBigDecimal(byte[] buffer, int offset)
          Build a Java BigDecimal from a 16-byte IEEE 754 reversed byte floating point representation.
static double ieee754ReversedBytesToDouble(byte[] buffer, int offset)
          Build a Java double from an 8-byte IEEE 754 reversed byte floating point representation.
static float ieee754ReversedBytesToFloat(byte[] buffer, int offset)
          Build a Java float from a 4-byte IEEE 754 reversed byte floating point representation.
static BigDecimal vaxBytesToBigDecimal(byte[] buffer, int offset)
          Build a Java BigDecimal from a 16-byte vax floating point representation.
static double vaxBytesToDouble(byte[] buffer, int offset)
          Build a Java double from an 8-byte vax floating point representation.
static float vaxBytesToFloat(byte[] buffer, int offset)
          Build a Java float from a 4-byte vax floating point representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEXADECIMAL_FLOATING_POINT

public static final int HEXADECIMAL_FLOATING_POINT
Supported System/390 hexadecimal floating point representation.

IEEE_754_FLOATING_POINT

public static final int IEEE_754_FLOATING_POINT
Supported AS/400, Unix Big Endian IEEE 754 floating point representation.

IEEE_754_FLOATING_POINT_BYTE_REVERSED

public static final int IEEE_754_FLOATING_POINT_BYTE_REVERSED
Supported Intel 80/86 Little Endian IEEE 754 floating point representation.

VAX_BINARY_FLOATING_POINT

public static final int VAX_BINARY_FLOATING_POINT
Placeholder for future support of VAX floating point representation.
Method Detail

getFloat

public static float getFloat(byte[] buffer,
                             int offset,
                             int representation)
Build a Java float from a 4-byte floating point representation.

Supported 4-byte representations are:

This includes DB2 types:

Throws:
IllegalArgumentException - if the specified representation is not recognized.

getDouble

public static double getDouble(byte[] buffer,
                               int offset,
                               int representation)
Build a Java double from an 8-byte floating point representation.

Supported 8-byte representations are:

This includes DB2 types:

Throws:
IllegalArgumentException - if the specified representation is not recognized.

getBigDecimal

public static BigDecimal getBigDecimal(byte[] buffer,
                                       int offset,
                                       int representation)
Build a java.math.BigDecimal from a 16-byte floating point representation.

Supported 16-byte representations are:

FLOAT16 is not currently a DB2 column type, but DRDA does provide for FLOAT16.

Throws:
IllegalArgumentException - if the specified representation is not recognized.

ieee754BytesToFloat

public static float ieee754BytesToFloat(byte[] buffer,
                                        int offset)
Build a Java float from a 4-byte IEEE 754 floating point representation.

ieee754ReversedBytesToFloat

public static float ieee754ReversedBytesToFloat(byte[] buffer,
                                                int offset)
Build a Java float from a 4-byte IEEE 754 reversed byte floating point representation.

hexadecimalBytesToFloat

public static float hexadecimalBytesToFloat(byte[] buffer,
                                            int offset)
Build a Java float from a 4-byte hexadecimal floating point representation.

vaxBytesToFloat

public static float vaxBytesToFloat(byte[] buffer,
                                    int offset)
Build a Java float from a 4-byte vax floating point representation.
Throws:
UnsupportedOperationException - not yet implemented.

ieee754BytesToDouble

public static double ieee754BytesToDouble(byte[] buffer,
                                          int offset)
Build a Java double from an 8-byte IEEE 754 floating point representation.

ieee754ReversedBytesToDouble

public static double ieee754ReversedBytesToDouble(byte[] buffer,
                                                  int offset)
Build a Java double from an 8-byte IEEE 754 reversed byte floating point representation.

hexadecimalBytesToDouble

public static double hexadecimalBytesToDouble(byte[] buffer,
                                              int offset)
Build a Java double from an 8-byte hexadecimal floating point representation.

vaxBytesToDouble

public static double vaxBytesToDouble(byte[] buffer,
                                      int offset)
Build a Java double from an 8-byte vax floating point representation.
Throws:
UnsupportedOperationException - not yet implemented.

ieee754BytesToBigDecimal

public static BigDecimal ieee754BytesToBigDecimal(byte[] buffer,
                                                  int offset)
Build a Java BigDecimal from a 16-byte IEEE 754 floating point representation.
Throws:
UnsupportedOperationException - not yet implemented.

ieee754ReversedBytesToBigDecimal

public static BigDecimal ieee754ReversedBytesToBigDecimal(byte[] buffer,
                                                          int offset)
Build a Java BigDecimal from a 16-byte IEEE 754 reversed byte floating point representation.
Throws:
UnsupportedOperationException - not yet implemented.

hexadecimalBytesToBigDecimal

public static BigDecimal hexadecimalBytesToBigDecimal(byte[] buffer,
                                                      int offset)
Build a Java BigDecimal from a 16-byte hexadecimal floating point representation.
Throws:
UnsupportedOperationException - not yet implemented.

vaxBytesToBigDecimal

public static BigDecimal vaxBytesToBigDecimal(byte[] buffer,
                                              int offset)
Build a Java BigDecimal from a 16-byte vax floating point representation.
Throws:
UnsupportedOperationException - not yet implemented.

Draft 01/30/01

Send comments or suggestions to jcc@us.ibm.com