]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix sig11 when dividing large bignums
authorslava <slava@factorcode.org>
Thu, 9 Nov 2006 23:10:02 +0000 (23:10 +0000)
committerslava <slava@factorcode.org>
Thu, 9 Nov 2006 23:10:02 +0000 (23:10 +0000)
library/test/math/integer.factor
vm/bignum.c
vm/data_gc.h

index 7928ed7f6dd17ee1db2db8e5e334afa1c6e546f2..9860763f4c8cb279de844785d508a85f2263aaf4 100644 (file)
@@ -105,3 +105,10 @@ unit-test
 [ t ] [ 0 >bignum zero? ] unit-test
 
 [ 4294967280 ] [ 268435455 >fixnum 16 fixnum* ] unit-test
+
+[ 23603949310011464311086123800853779733506160743636399259558684142844552151041 ]
+[
+    1957739506503920732625800353008742584087090810400921800808997218266517557963281171906190947801528098188887586755474449585677502695226712388326288208691204
+    79562815144503850065234921197651376510595262628033069372760833939060637564931
+    bignum-mod
+] unit-test
index 51bd4583bd82f9808c1ed03cf2428bed96b49802..a62617585779181f3112469aafc6f4d8cbaba443 100644 (file)
@@ -847,7 +847,8 @@ bignum_divide_unsigned_large_denominator(bignum_type numerator,
     }
 
   REGISTER_BIGNUM(u);
-  q = bignum_trim (q);
+  if(q)
+    q = bignum_trim (q);
   UNREGISTER_BIGNUM(u);
 
   REGISTER_BIGNUM(q);
index c0bd754f32254a0d7b3d5d2ea9d428cbbb51af3f..cf869fa72121e120bd32405d0d89c1a1d28fc4ae 100644 (file)
@@ -231,8 +231,8 @@ INLINE bool root_push_alien(const void *ptr)
 #define UNREGISTER_C_STRING(obj) \
        if(obj##_root) obj = alien_offset(root_pop())
 
-#define REGISTER_BIGNUM(obj) root_push(tag_bignum(obj))
-#define UNREGISTER_BIGNUM(obj) obj = (untag_bignum_fast(root_pop()))
+#define REGISTER_BIGNUM(obj) if(obj) root_push(tag_bignum(obj))
+#define UNREGISTER_BIGNUM(obj) if(obj) obj = (untag_bignum_fast(root_pop()))
 
 INLINE void *allot_zone(F_ZONE *z, CELL a)
 {