[Gnucash-changes] fix the test case; it really is an overflow on division, there's a

Linas Vepstas linas at cvs.gnucash.org
Sat Jun 26 19:10:40 EDT 2004


Log Message:
-----------
fix the test case; it really is an overflow on division, 
there's a bunch of huge prime numbers involved.

Modified Files:
--------------
    gnucash/src/engine/test:
        test-numeric.c

Revision Data
-------------
Index: test-numeric.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/test/test-numeric.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lsrc/engine/test/test-numeric.c -Lsrc/engine/test/test-numeric.c -u -r1.11 -r1.12
--- src/engine/test/test-numeric.c
+++ src/engine/test/test-numeric.c
@@ -543,12 +543,19 @@
 		}
 
 	}
-
 	a = gnc_numeric_create(782592055622866ULL,89025);
 	b = gnc_numeric_create(2222554708930978ULL,85568);
-	/* XXX: I'm not 100% sure that this is the value we should get, but
-	 * we probably should NOT get ERROR -2 / 0 */
-	check_binary_op (gnc_numeric_create(2578135489ULL, 7617691200ULL),
+	/* Dividing the above pair overflows.  This can be seen from
+	 * the factorization int primes:
+	 * 782592055622866 = 2 * 2283317 * 171371749
+	 * (yes, thats a seven and a nine digit prime)
+	 * 2222554708930978 = 2 * 1111277354465489
+	 * (yes, that's a sixteen-digit prime number)
+	 * 89025 = 3*5*5*1187 
+	 * 85568= 64*7*191   
+	 * You can do this by hand and see that it overflows.
+	 */
+	check_binary_op (gnc_numeric_create(GNC_ERROR_OVERFLOW, 0),
 			 gnc_numeric_div(a, b, GNC_DENOM_AUTO,
 					 GNC_DENOM_SIGFIGS(6) | GNC_RND_ROUND),
 			 a, b, "expected %s got %s = %s / %s for div round");


More information about the gnucash-changes mailing list