[AccessD] roundup - decimal places

Heenan, Lambert Lambert.Heenan at AIG.com
Tue Apr 8 09:00:08 CDT 2003


To quote from the (much maligned) on-line help...

Currency variables are stored as 64-bit (8-byte) numbers in an integer
format, scaled by 10,000 to give a fixed-point number with 15 digits to the
left of the decimal point and 4 digits to the right.

As it's an integer value, even binary computers can do the match right.
Integers are represented exactly. It's only floating point numbers where
there are approximations.

Lambert

> -----Original Message-----
> From:	John W. Colby [SMTP:jcolby at colbyconsulting.com]
> Sent:	Tuesday, April 08, 2003 9:12 AM
> To:	accessd at databaseadvisors.com
> Subject:	RE: [AccessD] roundup - decimal places
> 
> Charles,
>  
> Are you sure that Currency is just a scaled floating pt number?  I'm sure
> you know, but for the edification of those who may not, in the old days
> you had a form of data called BCD for binary coded decimal.  BCD is a
> system where decimal DIGITS are stored in 4 bits.  Since 4 bits can
> represent the values 1-15, any decimal digit can then be represented
> exactly without any rounding error at all due to inexact representation in
> binary storage.  Then a program (functions in the math library) would
> manipulate strings of binary coded decimal DIGITS to allow absolutely
> precise decimal arithmetic out to the specified precision, with no errors
> introduced due to binary storage techniques.  It was my understanding that
> the currency datatype was a BCD datatype, scaled to 4 decimal digits right
> of the decimal point.
>  
> My understanding also is that floating point numbers are simply a binary
> approximation stored in an 80 bit number with various combinations of the
> bits used for the digit and the fraction.  Thus NO floating point numbers
> (results) can be guaranteed to be correct if enough calculations are
> performed since the results are always stored back into a binary format,
> introducing binary storage errors in representing what are supposed to be
> decimal numbers (down in the lowest decimal digit).  IOW, the rightmost
> digit will ALWAYS have an error, and as you perform more and more
> calculations, those errors may "creep" upwards into the next digit, and
> the next etc.  The more calculations you perform, the more error creep may
> possibly occur.
>  
> BCD, and Currency IF it is based on BCD, will never have this error creep
> since the system is based on exact representations of decimal DIGITS and
> no binary representation is ever used at any stage of the calculation.
> 
> John W. Colby


More information about the AccessD mailing list