4.2.3: mpf_set_str() no longer recognizes exponents with '+' prefix

Torbjorn Granlund tg at swox.com
Sat Aug 16 12:06:14 CEST 2008


Jan Andres <jandres at gmx.net> writes:

  Strings like "1e+3" are no more recognized by mpf_set_str() in 4.2.3,
  only "1e3" is.

Indeed it isn't, but it never was.

  This is a bit troublesome as on the other hand,
  gmp_printf() and friends do output a '+'-prefixed exponent when using
  the "%g" format. See below for proposed fix.
    
  --- gmp-4.2.3/mpf/set_str.c.orig	2007-12-10 05:47:18.000000000 +0100
  +++ gmp-4.2.3/mpf/set_str.c	2008-08-16 11:51:14.000000000 +0200
  @@ -274,7 +274,8 @@
         {
   	/* Scan and convert the exponent, in base exp_base.  */
   	long dig, neg = -(long) ('-' == expptr[0]);
  -	expptr -= neg;			/* conditional increment */
  +	if (neg || expptr[0] == '+')
  +	  expptr++;
   	c = (unsigned char) *expptr++;
   	dig = digit_value[c];
   	if (dig >= exp_base)

I suppose we should do something like that.

-- 
Torbjörn


More information about the gmp-bugs mailing list