[ros-diffs] [gschneider] 41799: Geoffroy Couprie <geo DOT couprie AT gmail DOT com>: - Fix a printf case, where the exponent is zero - Implement exponent increment/decrement for printf in scientific notation My changes <grschneider AT gmail DOT com>: - Change some lessequal/greaterequal to equal - Exchange OR with AND operation - Modify patch identation to match current code, remove FIXME - Skipped the ecvt part of the patch (not needed, sprint has the bugs) - Fixes five msvcrt printf winetests, see bug #4584 for more information

gschneider at svn.reactos.org gschneider at svn.reactos.org
Tue Jul 7 18:19:35 CEST 2009


Author: gschneider
Date: Tue Jul  7 20:19:34 2009
New Revision: 41799

URL: http://svn.reactos.org/svn/reactos?rev=41799&view=rev
Log:
Geoffroy Couprie <geo DOT couprie AT gmail DOT com>:
- Fix a printf case, where the exponent is zero
- Implement exponent increment/decrement for printf in scientific notation
My changes <grschneider AT gmail DOT com>:
- Change some lessequal/greaterequal to equal
- Exchange OR with AND operation
- Modify patch identation to match current code, remove FIXME
- Skipped the ecvt part of the patch (not needed, sprint has the bugs)
- Fixes five msvcrt printf winetests, see bug #4584 for more information

Modified:
    trunk/reactos/lib/sdk/crt/stdio/lnx_sprintf.c

Modified: trunk/reactos/lib/sdk/crt/stdio/lnx_sprintf.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/lnx_sprintf.c?rev=41799&r1=41798&r2=41799&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/lnx_sprintf.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/lnx_sprintf.c [iso-8859-1] Tue Jul  7 20:19:34 2009
@@ -168,7 +168,7 @@
 	int ro = 0;
 	int isize;
 
-	double frac, intr;
+	double num2, frac, intr;
 	double p;
 
 	char c, sign, digits[66];
@@ -185,7 +185,12 @@
 	if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' )
 	{
 		ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff);
-		exponent = ie/3.321928;
+		if (*n.__n == 0.0)
+			exponent = 0.0;
+		else
+		{
+			exponent = ie/3.321928;
+		}
 	}
 
 	if ( exp_sign == 'g' || exp_sign == 'G' )
@@ -201,17 +206,27 @@
 	if ( exp_sign == 'e' ||  exp_sign == 'E' )
 	{
 		frac = modf(exponent,&e);
-		/* FIXME: this exponent over-/underflow scheme doesn't comply with the wanted behaviour 
-		 * needed at all or completely different in original? */
-#if 0
-		if ( frac > 0.5 )
+		if (num < 0.0)
+			e--;
+		if (frac >= 0.5)
 			e++;
-		else if (  frac < -0.5  )
+		else if (frac < -0.5)
 			e--;
-#endif
+
+		num2 = num/pow(10.0L,(long double)e);
+		if (num2 < 1.0 && num2 > -1.0)
+		{
+			e--;
+			num2 = num/pow(10.0L,(long double)e);
+		}
+		else if (num2 < -10.0 && num2 > 10.0)
+		{
+			e++;
+			num2 = num/pow(10.0L,(long double)e);
+		}
 
 		/* size-5 because "e+abc" is going to follow */
-		buf = numberf(buf, end, num/pow(10.0L,(long double)e), 'f', size-5, precision, type);
+		buf = numberf(buf, end, num2, 'f', size-5, precision, type);
 		isize = 4;
 		while(*(buf-1) == ' ')
 		{



More information about the Ros-diffs mailing list