Decimal Encoding Sample Code

Sample code to illustrate encoding of decimal floating-point numbers in binary bit strings, and corresponding decoding.

See:
          Description

Packages
com.ibm.eou.decimal  

 

Sample code to illustrate encoding of decimal floating-point numbers in binary bit strings, and corresponding decoding.

Please see the document “General Decimal Arithmetic Encodings” at http://speleotrove.com/decimal for a full description of the encoding formats used.

This sample code provides a library of static methods to perform various encoding and decoding operations. The principal entry points are the methods on DecimalEncoder and on DecimalDecoder. This sample code also includes some support classes for expressing floating-point numbers in a generic “model” form, and for expressing binary bit strings, and these are used as inputs to and outputs from a number of the encoding and decoding methods.

This sample code is experimental, and may contain errors. It is offered on an as-is basis. In particular, this sample code is designed to be illustrative rather than to be an implementation optimised for any particular purpose. Indeed, a number of obvious optimisations are omitted in the interests of maximising clarity.

Please send comments, suggestions, and corrections to the author:
    Dave Clark
    IBM UK Ltd, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK
    dave.clark@uk.ibm.com