Re: Fixed Point Arithmetic

From: Bob Badour <bbadour_at_pei.sympatico.ca>
Date: Thu, 29 Mar 2007 17:36:27 GMT
Message-ID: <vOSOh.16996$PV3.175098_at_ursa-nb00s0.nbnet.nb.ca>


David Cressey wrote:

> The recent threads on possreps and floating point made me think about fixed
> point arithmetic, again. I'm going to refer you to the Wikipedia entry on
> fixed point arithmetic, as a starting point for our discussion.
>
> There's a comparison in there between floating point, binary fixed point,
> and so called BCD fixed point, or decimal fixed point. At the risk of
> incorrect usage, I'm going to start out by discussing
> decimal fixed point arithmetic with a scale factor of 2. The scale factor
> of two means that there are two digits after the decimal point. The total
> precision of the fixed point numbers depends on the way they are stored.
>
> An example of a literal in this format is 12345.67
>
> This format is useful for storing and calculating currency amounts, where
> the smallest unit is one hundredth of the standard unit. If the standard
> unit is the US dollar, then the penny is the smallest unit. The UK pound
> is decimalized in this fashion, if I recall correctly.
>
> In the abstract, these FP numbers exhibit closure over addition and
> subtraction. They also exhibit closure over multiplication by an integer,
> because multiplication by an integer can be reduced to repetitive addtion or
> subtraction. In finite computing, additions may produce overflow where
> floating point numbers would have produced roundoff error instead.
>
> These FP numbers do not have closure over multiplication, because the
> product may have up to four significant digits after the decimal point, and
> therefore have to be rounded off for storage purposes.
>
> Anyway, I'm going to say that FP numbers with a scale factor of 2 save an
> enormous amount of head-scratching when working with bean counting
> applications. You won't spend time looking for the missing penny. OTOH,
> if you use these numbers for complicated arithmetic (example: amortization
> schedule) you have to think about roundoff errors.
>
> When it comes to the stock market, it depends on the country. AFAIK, the
> NYSE still records stock "points" in units of dollars, with binary
> fractional points like 1/4, 1/32, and the like. The use of decimal FPs
> with this kind of data will introduce round off problems that would have
> been avoided with binary floating point numbers.
>
> It's my understanding that the Australian stock market recently went through
> a transition from binary fractions like the NYSE to decimal fractions,
> like the currency. I would have expected some problems to surface in the IT
> systems that massage that data for precisely this reason.
>
> Does anyone here have any experience with the decimalization of the
> Australian stock market? Did it cause problems? Did it obviate some prior
> roundoff problems?
>
> Are fixed point numbers a useful from for DBMSes to support?

Logical and physical independence demand one answer the last question with "Yes, absolutely". Received on Thu Mar 29 2007 - 19:36:27 CEST

Original text of this message