The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » sci.math.* » sci.math

Topic: bcd arithmetic
Replies: 1   Last Post: Jun 17, 1996 1:54 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Michael D Shapiro

Posts: 2
Registered: 12/12/04
Re: bcd arithmetic
Posted: Jun 17, 1996 1:54 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

In article <4phmie$>,
Dann Corbit <> wrote:
>In article <>, says...
>>In other words: for U.S. currency, you keep track of cents. Not
>>dollars. Cents.

>This approach works in simplistic terms, for instance, when you are adding
>two amounts. But how do you figure tax using only integers? If you
>use only integer types, how do you figure interest, which is an exponential?
>You are back to using floating point in either case, which never eliminates
>the problem.
>All real world accounting systems have to deal with non-integer amounts at
>some point in the calculation stream.

To handle numeric data of this type, you need fixed point arithmetic,
not integer arithmetic. Decimal fixed point arithmetic keeps the
decimal (not binary) point a fixed number of digits from the right end
of the field. It uses decimal arithmetic rules for rounding and
truncation. Integer arithmetic is a special case of fixed point
arithmetic, with zero digits to the right of the point.

Fixed point numbers can be represented in any numeric format. The
"trick" to dealing with them correctly is in doing the correct
rounding, truncation, and scaling after *each* operation. Since many
of the computers we use do not have decimal fixed point arithmetic
built into the hardware, it becomes a software exercise (that is often
done incorrectly by those who don't understand all the implications).
Michael D. Shapiro, Ph.D. Internet:
Code 4123, NCCOSC RDT&E Division (NRaD) San Diego CA 92152
Voice: (619) 553-4080 FAX: (619) 553-4808 DSN: 553-4080

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2017. All Rights Reserved.