Boost logo

Boost :

From: Rainer Deyke (rainerd_at_[hidden])
Date: 2003-07-21 11:26:36


Keith Burton wrote:
> Using the notation Dn where n is the ( fixed ) scale of the decimal.
>
> D5 = D2 * D3 ;
>
> D2 = D2 * D3 ;
>
> Both are valid and realistic requirements for a decimal library.
> The first loses accurary unless the calculation preserves 5 decimal
> places.
> The second can overflow even when the answer would not unless the
> calculation preserves precision.

The second can overflow anyway if the multiplication is implemented as an
integer multiplication followed by a scale adjustment.

> The way my library dealt with was to use an intermediate result with
> greater precision / scale than allowed on the public interface. I have
> not checked the proposed library to see if this is a possibility for
> it.

Expression templates would be another approach.

-- 
Rainer Deyke - rainerd_at_[hidden] - http://eldwood.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk