On 14 December 2015 at 11:41, <highcalcula...@gmail.com> wrote: > Alright, thanks! > > Does this mean that I have to mpf_set_default_prec always before the first > mpf_... declaration? >
I would say so, yes. It sets the precision for any subsequent variables. At least that is my understanding. Bill. > Best, > P > > On Monday, December 14, 2015 at 11:24:02 AM UTC+1, Bill Hart wrote: >> >> You are setting the default precision before initialising z. I guess this >> means z has the previous default precision, which is probably 64 bits or >> something like that. >> >> Bill. >> >> On 14 December 2015 at 11:16, <highcal...@gmail.com> wrote: >> >>> Dear Bill, Dear All, >>> >>> I am trying to simply assign a passed mpf_t (y in the function) to >>> another mpf_t (x). The code suggest inaccuracy after 20 digits. >>> Here is the function, ctest.c: >>> >>> #include <stdio.h> >>> #include "mpir.h" >>> #include "ctest.h" >>> >>> void ctest(mpf_t y) >>> { >>> mpf_set_default_prec(10000); >>> >>> mpf_t x; mpf_inits(x, 0); >>> gmp_printf("x, y are %.*Ff, %.*Ff \n", 70, x, 70, y); >>> mpf_set(x, y); >>> gmp_printf("x, y are %.*Ff, %.*Ff \n", 70, x, 70, y); >>> >>> mpf_clears(x, 0); >>> } >>> >>> and here is the calling routine, ctest_main.c: >>> >>> #include <stdio.h> >>> #include "mpir.h" >>> #include "ctest.h" >>> >>> int main(void) { >>> FILE *finput; char tfile[] = "t1.txt"; // contains one number: >>> 1000000000000.000 and 80 trailing zeros >>> >>> mpf_t z; mpf_inits(z, 0); >>> >>> mpf_set_default_prec(10000); >>> >>> finput = fopen(tfile, "r"); >>> mpf_inp_str(z, finput, 10); >>> fclose(finput); >>> >>> ctest(z); >>> >>> mpf_clears(z, 0); return(0); >>> } >>> >>> This results in the output: >>> >>> x, y are >>> 0.0000000000000000000000000000000000000000000000000000000000000000000000 >>> , >>> 1000000000000.0000000000000000000000000000000000000000000000000000000000000000000000 >>> >>> x, y are >>> 1000000000000.0000000000000000001626303258728256651011179201304912567138671875000000 >>> , >>> 1000000000000.0000000000000000000000000000000000000000000000000000000000000000000000 >>> >>> >> >>> I am compiling (via Matlab, but this has not been an issue so far) by >>> >>> !gcc ctest_main.c ctest.c -LC:/MPIR/mpir-2.7.0/ -lmpir -o ctest_main >>> >>> Declaring y as an mpf_t in the function gave an error by the compiler. >>> Is this a bug? >>> >>> Thanks, >>> Pat >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "mpir-devel" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to mpir-devel+...@googlegroups.com. >>> To post to this group, send email to mpir-...@googlegroups.com. >>> Visit this group at https://groups.google.com/group/mpir-devel. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "mpir-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mpir-devel+unsubscr...@googlegroups.com. > To post to this group, send email to mpir-devel@googlegroups.com. > Visit this group at https://groups.google.com/group/mpir-devel. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to mpir-devel+unsubscr...@googlegroups.com. To post to this group, send email to mpir-devel@googlegroups.com. Visit this group at https://groups.google.com/group/mpir-devel. For more options, visit https://groups.google.com/d/optout.