Re: arithmetic

new topic     » topic index » view thread      » older message » newer message

When I was a commercial (government industry) programmer in C and Java, the
only real solution to avoid what I call the accountants problem ( 34.32 +
7.42 not being equal to 41.74) was to represent money in cents units,
process them, and print the final results scaled by 100.
Regards.
----- Original Message -----
From: <irv at take.maxleft.com>
To: "EUforum" <EUforum at topica.com>
Subject: RE: arithmetic


>
>
> rforno at tutopia.com wrote:
> > You should investigate the same problem in FORTRAN, BASIC, C, C++, Java,
> > Pascal and other languages.. None of these allows for exact equality for
> > floating point data. C does not allow = sign to compare strings; instead
> > you
> > should use strcmp() function; and so on.  COBOL, ABC (from the
> > Netherlands)
> > and APL are among the few that consider equality for float data, in
> > different ways each of them.
>
> Rob 'could' implement Theodore Belding's fcmp library.
> It slows down floating-point comparisons (in C) by 9x,
> but that shouldn't matter much. Even if he did, it wouldn't
> solve George's problem, however. The solution to that is
> either using integer math (easy) or a BCD math package
> (also easy, except that someone has to write one first ;)
>
> Regards,
> Irv
>
>
>
>

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu