float lower limit at given precision

Richard B. Kreckel kreckel at ginac.de
Fri Feb 24 10:08:36 CET 2012


Hi!

On 02/24/2012 01:48 AM, Slava Feshchenko wrote:
> The mantissa [is] stored in binary, as might be imagined from the fact
> precisions are expressed in bits. One consequence of this is that decimal
> fractions like 0.1 cannot be represented exactly. The same is true of plain
> IEEE double floats. This makes both highly unsuitable for calculations
> involving money or other values that should be exact decimal fractions.
> (Suitably scaled integers, or perhaps rationals, are better choices.)
>
> Therefore, in the absence of complete understanding of that person's
> computation requirements, especially if he stated that he needs high
> precision calculations, I thought it would be prudent to warn him of this
> limitation of mpf_t type. In the end it's up to him to decide what base is
> acceptable: 10 or 2 and wheather he wants to specify precision in bits or
> decimals digits.

Jacopo said he is "a student in theoretical physics" on a quest to 
"diagonalise a matrix with great precision" and, in particular, "to chop 
off the small elements from a vector". He did /not/ say he wants to chop 
off the small decimal digits of elements of a vector and he is /not/ 
doing "calculations involving money or other values that should be exact 
decimal fractions".

I'm quite sure that in this context the issue of base 10 vs. base 2 is a 
complete red herring. His problem can be solved in any base, and any 
base other than base 2 is a waste of CPU cycles.

Bye!
   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>


More information about the gmp-discuss mailing list