com.ibm.eou.decimal
Class BinaryUtilities

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

public final class BinaryUtilities
extends java.lang.Object

This class provides a library of static utility functions for handling binary encodings and decodings.

Author:
Dave Clark, IBM Ease of Use

Method Summary
static int packDPD(int digit1, int digit2, int digit3)
          Pack three decimal digits (0-9) into 10 bits using Densely-Packed Decimal (DPD) format.
static int[] unpackDPD(int bits)
          Unpack 10 bits in Densely-Packed Decimal (DPD) format into three decimal digits (0-9).
static void unpackDPD(int bits, int[] result, int index)
          Unpack 10 bits in Densely-Packed Decimal (DPD) format into three decimal digits (0-9), writing the three digit values into the specified array at the supplied position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

packDPD

public static int packDPD(int digit1,
                          int digit2,
                          int digit3)
Pack three decimal digits (0-9) into 10 bits using Densely-Packed Decimal (DPD) format.

Parameters:
digit1 - the first of the three digits to be packed.
digit2 - the second of the three digits to be packed.
digit3 - the third of the three digits to be packed.
Returns:
the result of packing the three digits using DPD format, with the first bit in bit 9 and the last bit in bit 0 of the returned int.

unpackDPD

public static int[] unpackDPD(int bits)
Unpack 10 bits in Densely-Packed Decimal (DPD) format into three decimal digits (0-9).

Parameters:
bits - three decimal digits packed using DPD format, with the first bit in bit 9 and the last bit in bit 0 of an int.
Returns:
an array of exactly three ints containing the three decimal digits.

unpackDPD

public static void unpackDPD(int bits,
                             int[] result,
                             int index)
Unpack 10 bits in Densely-Packed Decimal (DPD) format into three decimal digits (0-9), writing the three digit values into the specified array at the supplied position.

Parameters:
bits - three decimal digits packed using DPD format, with the first bit in bit 9 and the last bit in bit 0 of an int.
result - an array into which three integer digit values will be written.
index - the index into the array where the first integer digit value will be written. The second and third values will be written into the two successive positions.