[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: mpf_get_str trouble
From: |
Cesar Delgado |
Subject: |
RE: mpf_get_str trouble |
Date: |
Tue, 17 Dec 2002 18:54:16 -0600 |
I'm sorry to say that I'm still getting the same results when I work
with the program bellow. I downloaded gmp-4.1.1 from the website,
patched it, compiled it and installed it. I'm running the code on a
PentiumIII running RH7.3.
Thanks for the help,
-Cesar Delgado
---------------------------------------------
Secure Distributed Information @ UNL
http://rcf.unl.edu
address@hidden, address@hidden
> -----Original Message-----
> From: address@hidden [mailto:address@hidden On Behalf Of
Torbjorn
> Granlund
> Sent: Tuesday, December 17, 2002 11:25 AM
> To: Cesar Delgado
> Cc: address@hidden
> Subject: Re: mpf_get_str trouble
>
> "Cesar Delgado" <address@hidden> writes:
>
> I sent this email to the users mailing list and was told to send it
> here. If a better description of the problem is needed please don't
> hesitate in contacting me and I will try to supply the needed
> information.
>
> #include <stdio.h>
> #include <gmp.h>
>
> int main() {
>
> mpf_t number ;
> mp_exp_t exponent ;
> char *word ;
>
> mpf_init(number) ;
> mpf_init(one) ;
>
> mpf_set_ui(number, 1) ;
> mpf_div_ui(number, number, 5) ;
> mpf_pow_ui(number, number, 365) ;
> mpf_div_ui(number, number, 365) ;
>
> gmp_printf("%1.*Ff\n", 450, number) ;
> word = mpf_get_str(NULL, &exponent, 10, 0, number) ;
> printf("exponent = %li\n", (long int)exponent) ;
> }
>
> I get:
>
>
0.0000000000000000000000000000000000000000000000000000000000000000000000
>
000000000000000000000000000000000000000000000000000000000000000000000000
>
000000000000000000000000000000000000000000000000000000000000000000000000
>
000000000000000000000000000000000000000000000000000000000000000000000000
>
000000000000000000000000000000000000000000000000000000000000000000000000
>
000000000000000000000000000000000000000000000000000000000000000000000000
>
000000000000000000000000000000000000000000000000000000000000000000000000
>
000000000020589962369524017340100000000000000000000000000000000000000000
>
000000000000000000000000000000000000000000000000000000000000000000000000
> 00000000000000000000000000000000000000000000000000000000000
> exponent = -257
>
> Please apply the patch below and tell me if things now work as
> expected. This bug has such serious implications that it will
> trigger a new patch release, GMP 4.1.2.
>
> This patch fixes the problem with too many leading zeros. It
> looks odd to me that the number ends with many zeros, but perhaps
> gmp_printf is defined to pad with zeros rather than develop
> semi-spurious digits.
>
> Index: printf/printffuns.c
> ===================================================================
> RCS file: /home/cvsfiles/gmp/printf/printffuns.c,v
> retrieving revision 1.3
> retrieving revision 1.4
> diff -c -1 -r1.3 -r1.4
> *** printf/printffuns.c 24 Jul 2001 23:41:52 -0000 1.3
> --- printf/printffuns.c 17 Dec 2002 16:57:56 -0000 1.4
> ***************
> *** 61,65 ****
> memset (buf, c, MIN (reps, sizeof (buf)));
> ! for (i = reps; i > 0; i -= piece)
> {
> ! piece = MIN (reps, sizeof (buf));
> ret = fwrite (buf, 1, piece, fp);
> --- 61,65 ----
> memset (buf, c, MIN (reps, sizeof (buf)));
> ! for (i = reps; i > 0; i -= sizeof (buf))
> {
> ! piece = MIN (i, sizeof (buf));
> ret = fwrite (buf, 1, piece, fp);
>
> --
> Torbjörn