com.ibm.eou.decimal
Class DecimalDecoder

java.lang.Object
  |
  +--com.ibm.eou.decimal.DecimalDecoder

public final class DecimalDecoder
extends java.lang.Object

This class provides static library methods for interpreting and decoding binary representations of decimal floating-point numbers using the decimal32, decimal64 and decimal128 formats.

Author:
Dave Clark, IBM Ease of Use

Method Summary
static ModelNumber decodeDecimal(BitString bits)
          Return a floating-point number obtained by parsing binary encodings of decimal floating-point numbers in the decimal32, decimal64 and decimal128 formats.
static DecimalConstants.DecimalEncoding getEncodingForNumberOfBits(int numberOfBits)
          Return the encoding which uses the specified number of bits.
static java.lang.String toDecimalEngineeringString(ModelNumber value)
          Return a string representation of the specified value in decimal 'Engineering' format.
static java.lang.String toDecimalScientificString(ModelNumber value)
          Return a string representation of the specified value in decimal 'Scientific' format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

decodeDecimal

public static ModelNumber decodeDecimal(BitString bits)
Return a floating-point number obtained by parsing binary encodings of decimal floating-point numbers in the decimal32, decimal64 and decimal128 formats.

Parameters:
bits - a bit field containing a DecimalNNN encoded value.
Returns:
a floating-point number.

getEncodingForNumberOfBits

public static DecimalConstants.DecimalEncoding getEncodingForNumberOfBits(int numberOfBits)
Return the encoding which uses the specified number of bits. This method always returns an encoding, or throws an exception if no DecimalNNN encoding uses that number of bits.

Returns:
the decimal encoding using the specified number of bits.
Throws:
java.lang.IllegalArgumentException - if there is no matching encoding.

toDecimalScientificString

public static java.lang.String toDecimalScientificString(ModelNumber value)
Return a string representation of the specified value in decimal 'Scientific' format.

Throws:
java.lang.IllegalArgumentException - if the value is finite and its coefficient is not expressed with a radix of 10.

toDecimalEngineeringString

public static java.lang.String toDecimalEngineeringString(ModelNumber value)
Return a string representation of the specified value in decimal 'Engineering' format.

Throws:
java.lang.IllegalArgumentException - if the value is finite and its coefficient is not expressed with a radix of 10.