[grisbi-cvs] grisbi/src gsb_real.c,1.75,1.76

Pierre Biava pbiava at users.sourceforge.net
Tue Apr 13 22:40:06 CEST 2010


Update of /cvsroot/grisbi/grisbi/src
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv19672

Modified Files:
	gsb_real.c 
Log Message:
back in initial conversion  of double in gsb_real

Index: gsb_real.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_real.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- gsb_real.c	10 Apr 2010 21:03:15 -0000	1.75
+++ gsb_real.c	13 Apr 2010 20:40:04 -0000	1.76
@@ -846,7 +846,7 @@
 	else
 	{
 		number = gsb_real_double_to_real_add_exponent (
-		                      (gdouble) number_1.mantissa / number_2.mantissa,
+		                      (gdouble) number_1.mantissa / (gdouble) number_2.mantissa,
 		                       number_1.exponent - number_2.exponent);
 	}
     return number;
@@ -869,42 +869,28 @@
 {
     gdouble tmp_double, decimal;
     gdouble maxlong;
-
 	gsb_real real_number = {0, exp_add};
-    maxlong = G_MAXLONG / 100;
 
-	if ( exp_add >= 9 )
+    maxlong = G_MAXLONG / 10;
+
+	if(exp_add >=9)
 		return null_real;
 
-    while ( real_number.exponent < 9 )
+	while ( ( ( decimal = modf ( number, &tmp_double ) ) ||
+		real_number.exponent < 0 ) &&
+		real_number.exponent < 9)
     {
-        decimal = modf ( number, &tmp_double );
-
-        if ( decimal == 0 )
-            break;
-        else if ( ( 1.0 - fabs ( decimal ) ) < 0.0000000001 )
-        {
-            if ( number > 0.0 )
-                number = tmp_double + 1;
-            else
-                number = tmp_double - 1;
-            break;
-        }
-        if ( real_number.exponent < 0 )
-            break;
-
         number = number * 10;
-        real_number.exponent ++;
+        real_number.exponent++;
 
-        if ( fabs ( number ) > maxlong )
-            number = rint ( number );
+        if (fabs (number) > maxlong)
+            number = rint (number);
     }
 	decimal = modf ( number, &tmp_double );
-	if ( ( ( real_number.exponent == ( 9 - exp_add ) ) ) && ( decimal >= 0.5 ) )
-		real_number.mantissa = ( ( glong ) number ) + 1;
+	if ( ( (real_number.exponent == (9-exp_add)) ) && (decimal >= 0.5) )
+		real_number.mantissa = ((glong) number ) + 1;
 	
-    real_number.mantissa = ( glong ) ( number );
-
+    real_number.mantissa = (glong) (number);
     return real_number;
 }
 



More information about the cvs mailing list