On Mar 19, 2004, at 2:12 AM, Paul M Foster wrote:
> Programmers:
>
> Anyone have tips on how to ensure high precision in mathematical
> operations dealing with floats and doubles in C? These numbers will
> typically be dollars, and I don't want a lot of imprecise results when
> doing math on them. (Because floats and doubles represent decimal
> numbers as binary, they're very prone to loss of precision.)
Don't use floats or doubles. Use the gmp library. It's a really
straightforward API. I've "converted" a couple of little C apps I had
to use gmp and it was really quick and painless. Plus, it's probably
already on your linux box.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"We all enter this world in the | Support Electronic Freedom
same way: naked; screaming; soaked | http://www.eff.org/
in blood. But if you live your | http://www.anti-dmca.org/
life right, that kind of thing |---------------------------
doesn't have to stop there." -- Dana Gould
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:26:46 EDT