mpf_set_d

delta trinity deltatrinity at hotmail.com
Sat Nov 22 14:20:33 CET 2003


You can adjust the precision of the mpf structure.

Either with mpf_set_default_prec, which set default precision for subsequent 
mpf_init, or with mpf_set_prec, in which case you can change precision of a 
specific mpf_t variable.

Note that if you already initialized and assigned a value to an mpf_t, 
increasing precision after that won't get you back the precision you lost 
during the assignment.  You need to re-assign your variable to it, or use 
mpf_set_default_prec before mpf_init.


Eric


>From: "Hee Jung Lee" <heejung73 at yahoo.com>
>To: <gmp-discuss at swox.com>
>Subject: mpf_set_d
>Date: Fri, 21 Nov 2003 17:10:23 -0800
>
>
>hi guys!
>
>this is probably a really basic question.  but!
>when i use mpf_set_d(), how do i make sure that
>the copy is "exact"?  for example, suppose my double
>value is 0.897959184, i want my mpf_t to be
>0.897959184000000000000000000000 and NOT
>0.897959183999999965841709581582
>
>src
>===
>#include <stdio.h>
>#include <stdlib.h>
>#include "gmp.h"
>
>int main()
>{
>	double d;
>	mpf_t m;
>
>	mpf_set_default_prec(400);
>	d = 0.897959184;
>	mpf_init(m);
>	mpf_set_d(m,d);
>	printf("\nd=%.16f", d);
>	gmp_printf("\nm=%.*Ffd",20,m);
>	mpf_clear(m);
>}
>
>output
>======
>d=0.8979591840000000
>m=0.897959183999999965841709581582d
>_______________________________________________
>gmp-discuss mailing list
>gmp-discuss at swox.com
>https://gmplib.org/mailman/listinfo/gmp-discuss

_________________________________________________________________
Set yourself up for fun at home!  Get tips on home entertainment equipment, 
video game reviews, and more here.   
http://special.msn.com/home/homeent.armx



More information about the gmp-discuss mailing list