Re: Why not FP for Money?

From: Carlos Ribeiro (carribeiro_at_gmail.com)
Date: 09/21/04


Date: Tue, 21 Sep 2004 09:56:38 -0300
To: Chris Barker <barkmann@gmail.com>

On 21 Sep 2004 00:25:25 -0700, Chris Barker <barkmann@gmail.com> wrote:
> If you were to use FP, you could have your IEEE 754 hardware do the
> rounding for you, and get better performance to boot. If you are
> rounding to cents at the end anyway, I can't see that the errors you'd
> get with 64 bit FP numbers would ever be an issue.

I'm not an expert either, but the best way to handle errors of any
kind is not to have them first place. Although what you're talking
about could possibly work, it would require extra care from the
programmer to make sure that all values would be thorougly checked and
rounded at the end of each and every operation. I'm not sure if this
can be made to work on large scale. The option would be to encapsulate
into a special purpose rounded-floating-point class. But then, I'm not
sure if the possible gains that you get from the use of IEEE754
accelerated hardware are worth the extra layer; in the end,
performance may be end up being similar to the one obtained with a
fixed point library.

There is another potential problem: I think that the biggest benefits
of the IEEE754 hardware would come with complex operations that are
directly supported by the hardware. For simple tasks that make the
bulk of money-handling code -- sums and multiplications -- integer
based code is probably as fast or faster, even with all the checks and
the scaling.

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro@gmail.com
mail: carribeiro@yahoo.com


Relevant Pages

  • Re: Maths error
    ... But the issue is really error build-up, ... An old, cheap approximation to rounding. ... I have been told by hardware people that implementing IEEE 754 rounding ...
    (comp.lang.python)
  • Re: Criticism of a proposed floating point (cs)prng requested.
    ... different branch officies of a firm are to confidentially communicate ... hardware, if not exactly identical hardware, for that purpose. ... differences due to rounding are tolerable. ...
    (sci.crypt)
  • Re: ROUND
    ... >> JK insisted that the PL/I ref. ... manual specified that a hardware ... >> OR instruction had to do the rounding. ...
    (comp.lang.pl1)
  • Re: ROUND
    ... hardware specific - and not in terms of the argument's actual base. ... ANS ROUND is non-portable, ... Although rounding takes place on output, ... not much call for decimal rounding via ROUND. ...
    (comp.lang.pl1)
  • Re: azameDisaster recovery of domain after an actual disaster?
    ... BLOG --> http://blogs.dirteam.com/blogs/jorge/default.aspx ... "Paul Bergson" wrote in message ... Please no e-mails, any questions should be posted in the NewsGroup This posting is provided "AS IS" with no warranties, and confers no rights. ... Virtual machines won't have a lot of the dependent driver restriction hardware machines have. ...
    (microsoft.public.windows.server.active_directory)