BCD Encoding?

Bill Wilson wew at naucse.UUCP
Fri Apr 13 06:53:43 AEST 1990


>From article <522 at dbase.A-T.COM>, by awd at dbase.A-T.COM (Alastair Dallas):
> The information is proprietary, but 1) even _I_ would vote to release it,
> I think (and I'm pretty conservative); and 2) Ashton-Tate is planning to
> release file format information in some form to some group of people
> (developers under non-disclosure, everyone, or something inbetween) soon.
> I will make it my business to find out more about our policy and respond
> to the net.
>
Well guess what?  I figured it out by myself.  Here it is in case
anyone else needs to do it.  You will need a hex dumper to get it 
perfect.

dBASE IV now has two numeric data types: fixed (BCD) and float.  There
are two forms to the fixed numbers in memory variable files: integer
and fixed decimal.  The integer uses a traight nibble=number encoding
that follows the standards that I have been made aware of through
helpful people on the net.  The second form is more complex in some
ways and just as simple in others.  The following is a description
of the format:

Field    N Bytes    Description
1          11        Variable name
2           1        Variable type
3           1        Var sub type
4          19        not sure what this area is for...
5           1        variable size/info
6           1        sign
7          10        BCD number

Field number five indicates the size of the variable.  It is based
on the number 34h.  If the size is greater than 34h, subtract 34h
from the number and that is the number of whole digits from the
beginning of the BCD number.  If the number is less than 34h then
the differnce is the number of extra zeros to put after the implied
decimal point and before the BCD number.  For example, if you have 
the hex bytes:
   36 0d 20 50
36h-34h=2 which means you take the first two nibbles as the whole
portion and the rest as the decimal portion.  So the number would
be 20.50  Simple Huh?

If the number was negative the 0d would be 8d.  The first nibble 
indicates the sign.

The following is a list of the variable type codes as listed in field
two:
c3 - string
ce - float (IEEE format)
cc - logical
c4 - date
c6 - BCD numeric (fixed)

Some articles were published in Data Based Advisor (V5 N4, N5) that
helped in decoding the memory variable files.  If anyone else figures 
anything else out on these files, please let me know.


-- 
Let sleeping dragons lie........               | The RoleMancer 
----------------------------------------------------------------
Bill Wilson             (Bitnet: ucc2wew at nauvm | wilson at nauvax)
Northern AZ Univ  Flagstaff, AZ 86011



More information about the Comp.lang.c mailing list