Re: This calculation is just wrong / computer can't count!

Tech-Archive recommends: Fix windows errors by optimizing your registry



OMG! This flame war has gone on long enough.

Here's a simple answer, GT: The built-in variables in C++ (float, double, et al) don't handle precision in the way you expect. Use an arbitrary precision library, of which there are several to choose from...

http://en.wikipedia.org/wiki/Bignum

As an example, see apfloat: http://www.apfloat.org/apfloat/faq.html

Eric
.



Relevant Pages

  • Re: Losing Precision from FLOAT in DBD::Informix
    ... The versions of CSDK and IDS are also not ... STSM, Informix Database Engineering, IBM Data Management ... >> are declared FLOAT. ... >> - where and why is the precision lost? ...
    (perl.dbi.users)
  • Re: converting float to double
    ... >> insists that I read the stock prices as float. ... >> Since everywhere else the system uses double to hold these prices, ... A 64 bit integer will correctly model currency to 18 digits (with ... calcuations in 110 digits of precision (so that things like interest ...
    (comp.lang.c)
  • Re: one-liner for characater replacement
    ... (previous snip, someone wrote) ... integer divide as a coefficient of a float polynomial. ... They consider magnitude, but not precision, so int to float is ...
    (comp.lang.fortran)
  • RE: Losing Precision from FLOAT in DBD::Informix
    ... Subject: Losing Precision from FLOAT in DBD::Informix ... An SQL FLOAT in Informix is equivalent to a C double. ... The alternative way to work it is to modify the switch so that the SQLFLOAT ... You may need to choose a different format for the value than ...
    (perl.dbi.users)
  • Re: Precision issue
    ... >reprfunction is for discovering, as precisely as possible, the actual ... a binary float can always be given a precise decimal ... I'm not sure if repr currently preserves the full precision of the ... num = int ...
    (comp.lang.python)