Numbers are a very important element of many computer records. They could be phone numbers, stock parts, prices, quantities just as a few examples. Numbers have to be represented in a way that a computer can handle and display them, and sometimes the simplest way is as a text string. Thus a phone number could be 1234449999.

Everybody will be aware of the Y2K problem that was generated by storing just 99 rather than 1999. This was done to save space in computer storage, and hence over the years there have been several methods implemented to help store data in fewer bytes. One of the most common ways which started on mainframes, and in Cobol is several variations of ‘Packed Decimal’, or COMP-3. Most computer storage is based on an 8 bit byte, that has the range of values from 0 to 255. If a single digit is stored in a byte then only 10 of the possible 256 combinations is used. It is therefore more efficient to store 2 numbers on a single byte, and so make use of 100 combinations (00-99).

The hex representation of the above phone number could therefore be

12 34 44 99 99

and so will store the 10 digits in 5 bytes.

Often though, a number needs to be signed, ie negative or positive and the standard for this is then to add a code at the of the string to represent positive or negative. Being in Hex, the values A – F are available, and C is positive (credit) and D is negative (debit) and F for unsigned. The number above would be

01 23 44 49 99 9F

It should be noted that this COMP-3 representation the length of numbers is always odd, but this can be taken care of in the application. The application processing the record will also add any implied decimal places.

These packed records are very common in mainframe records, but modern PC programs, such as Access can not handle them. It is therefore necessary to have a tool to convert these strings normally to straight text strings – in ASCII or EBCDIC. The eMag tool to do this is the Record Reformatter (RR32), in which record layouts can be defined and numbers converted as required. RR32 can also handle all other types of numbers, and dates.

For more details on packed numbers, please visit the RR32 product page. RR32 is an option in MediaMerge/PC, or can be run as a stand alone program.