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

Jan Andres jandres at gmx.net
Sat Aug 16 11:55:15 CEST 2008


Hi,

Strings like "1e+3" are no more recognized by mpf_set_str() in 4.2.3,
only "1e3" is. 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.

[OS, compiler info left out as this is a generic issue]


--- 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)

-- 
Jan Andres <jandres at gmx.net>


More information about the gmp-bugs mailing list