Home | Previous Page | Next Page   Getting Started with DB-Access > Invoking DB-Access >

Checking the Scale of DECIMAL(p) Values

In an ANSI-compliant database, columns declared as a DECIMAL(p) data type have a precision of p and a scale of zero, so that only integer values are stored. In a database that is not ANSI-compliant, DECIMAL(p) is a floating-point data type whose scale is large enough to store the exponential notation for a value.

For example, the following calculation shows how many bytes a DECIMAL(5) column requires in the default locale (where the decimal point occupies a single byte):

1 byte for the sign of the data value
1 byte for the 1st digit
1 byte for the decimal point
4 bytes for the rest of the digits (precision of 5 - 1)
1 byte for the e symbol
1 byte for the sign of the exponent
3 bytes for the exponent
-------------------------------------------------
12 bytes total

Thus, "12345" in a DECIMAL(5) column is displayed as "12345.00000" (that is, with a scale of 6) in a database that is not ANSI-compliant.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]