C++ mpf_class Precision

Henry henryxxll at gmail.com
Tue Jun 2 03:04:58 CEST 2009


What if I base the assignment of an mpf_class variable on another mpf_class
variable, like so:

*mpf_class a, b;
a="1.123456789123456789123456789";
b=a*2;
*
Would it still round it incorrectly?

On Mon, Jun 1, 2009 at 8:38 PM, Marc Glisse <marc.glisse at normalesup.org>wrote:

> On Mon, 1 Jun 2009, Henry wrote:
>
>  mpf_class x;
>> x=1.234567891234567899052395;
>>
>
> This is a general C question. When the compiler sees
> 1.234567891234567899052395, it thinks this is a double and rounds it
> accordingly. I think you actually want to go though a string:
> x="1.23...";
>
> In a few years, with C++0x, you may be able to write 1.234_mpf instead of
> mpf_class("1.234"), but that is still far away.
>
> --
> Marc Glisse
>



-- 
Henry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gmplib.org/list-archives/gmp-discuss/attachments/20090601/48321684/attachment.html>


More information about the gmp-discuss mailing list