<div dir="ltr">Hi, thank you for a good answer!<br><br>But when you point me to the mpfr library I am a bit confused.<br>I don't see how mpfr should work for "exactly" 6 bits etc. are you sure it works?<br>I thought that double precision is minimum there?<br>
<br>/best regards Joel kronander<br><br><div class="gmail_quote">On Mon, Sep 29, 2008 at 3:33 PM, Paul Zimmermann <span dir="ltr"><<a href="mailto:Paul.Zimmermann@loria.fr">Paul.Zimmermann@loria.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">> Date: Sun, 28 Sep 2008 22:47:50 +0200<br>
<div class="Ih2E3d">> From: "Joel Kronander" <<a href="mailto:joekr552@student.liu.se">joekr552@student.liu.se</a>><br>
><br>
</div><div><div></div><div class="Wj3C7c">> Hi<br>
><br>
> I have a question regading the possible minimun precision for floats.<br>
> For example is it possible to use a precision between native c float and<br>
> double<br>
> ie precision digits between 6-15 for exmample.<br>
><br>
><br>
> /best regards Joel Kronander<br>
<br>
</div></div>I guess your question is related to the mpf class. The manual says:<br>
<br>
The precision selected for a variable is a minimum value, GMP may<br>
increase it a little to facilitate efficient calculation. Currently<br>
this means rounding up to a whole limb, and then sometimes having a<br>
further partial limb, depending on the high limb of the mantissa. But<br>
applications shouldn't be concerned by such details.<br>
<br>
If you look in the internal file gmp-impl.h you will see:<br>
<br>
/* __GMPF_BITS_TO_PREC applies a minimum 53 bits, rounds upwards to a whole<br>
limb and adds an extra limb. __GMPF_PREC_TO_BITS drops that extra limb,<br>
hence giving back the user's size in bits rounded up. Notice that<br>
converting prec->bits->prec gives an unchanged value. */<br>
#define __GMPF_BITS_TO_PREC(n) \<br>
((mp_size_t) ((__GMP_MAX (53, n) + 2 * GMP_NUMB_BITS - 1) / GMP_NUMB_BITS))<br>
<br>
thus you *can* ask for a precision of 6 or 15 bits, but then GMP will allocate<br>
3 words on a 32-bit computer, and 2 words on a 64-bit computer, and it will<br>
have the same effect as if you had asked for 53 or 64 bits.<br>
<br>
If you want to have a precision of *exactly* 6 bits, I suggest you try MPFR<br>
(see <a href="http://mpfr.org" target="_blank">mpfr.org</a>). It also works for 15 bits.<br>
<font color="#888888"><br>
Paul Zimmermann<br>
<br>
<br>
</font></blockquote></div><br></div>