]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 23 Feb 2009 01:52:06 +0000 (19:52 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 23 Feb 2009 01:52:06 +0000 (19:52 -0600)
basis/math/bits/bits-tests.factor
basis/math/functions/functions-tests.factor
basis/math/miller-rabin/miller-rabin-tests.factor
core/math/integers/integers-tests.factor
extra/annotations/annotations-docs.factor
vm/bignum.c

index 0503d27f33c2f572d01db6c99a118d7e35844f36..ed4e8419c965911e3496df60ba19f12b716b9e19 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test math.bits sequences arrays ;
+USING: tools.test math math.bits sequences arrays ;
 IN: math.bits.tests
 
 [ t ] [ BIN: 111111 3 <bits> second ] unit-test
@@ -14,3 +14,18 @@ IN: math.bits.tests
 [ 2 ] [ -3 make-bits length ] unit-test
 [ 1 ] [ 1 make-bits length ] unit-test
 [ 1 ] [ -1 make-bits length ] unit-test
+
+! Odd bug
+[ t ] [
+    1067811677921310779 make-bits
+    1067811677921310779 >bignum make-bits
+    sequence=
+] unit-test
+
+[ t ] [
+    1067811677921310779 make-bits peek
+] unit-test
+
+[ t ] [
+    1067811677921310779 >bignum make-bits peek
+] unit-test
\ No newline at end of file
index cf0ce5f0bb5642b7f72e84fa6022a50eca9f9473..9f5ce36be1fb593bafc1277b6e7e86f592476539 100644 (file)
@@ -137,3 +137,17 @@ IN: math.functions.tests
 
 [ 6 59967 ] [ 3837888 factor-2s ] unit-test
 [ 6 -59967 ] [ -3837888 factor-2s ] unit-test
+
+[ 1 ] [
+    183009416410801897
+    1067811677921310779
+    2135623355842621559
+    ^mod
+] unit-test
+
+[ 1 ] [
+    183009416410801897
+    1067811677921310779
+    2135623355842621559
+    [ >bignum ] tri@ ^mod
+] unit-test
\ No newline at end of file
index 9ca85ea72c5681a63510afb795d8ee914b2d9ae6..5f1b9835e49c32b9739cfd59663d5f7d06e8fa57 100644 (file)
@@ -7,4 +7,5 @@ IN: math.miller-rabin.tests
 [ f ] [ 36 miller-rabin ] unit-test
 [ t ] [ 37 miller-rabin ] unit-test
 [ 101 ] [ 100 next-prime ] unit-test
-[ 100000000000031 ] [ 100000000000000 next-prime ] unit-test
+[ t ] [ 2135623355842621559 miller-rabin ] unit-test
+[ 100000000000031 ] [ 100000000000000 next-prime ] unit-test
\ No newline at end of file
index 5a649120a02962625aac1d4bbc1a842c15a9c6e1..6bd3e9b094cd1489176021ecd970993c141dba9e 100644 (file)
@@ -91,6 +91,8 @@ unit-test
 [ f ] [ BIN: -1101 >bignum 3 bit? ] unit-test
 [ t ] [ BIN: -1101 >bignum 4 bit? ] unit-test
 
+[ t ] [ 1067811677921310779 >bignum 59 bit? ] unit-test
+
 [ 2 ] [ 0 next-power-of-2 ] unit-test
 [ 2 ] [ 1 next-power-of-2 ] unit-test
 [ 2 ] [ 2 next-power-of-2 ] unit-test
index bf8aef3a07cbb8a1f9136d05238f809d8e14bf07..1bece9d4fbd5698e5c947da2cdfd71aee28fa8fb 100644 (file)
@@ -1,6 +1,6 @@
 USING: accessors arrays combinators definitions generalizations
 help help.markup help.topics kernel sequences sorting vocabs
-words ;
+words combinators.smart ;
 IN: annotations
 
 <PRIVATE
@@ -13,17 +13,35 @@ PRIVATE>
     first
     [ "!" " your comment here" surround 1array $syntax ]
     [ [ "Treats the rest of the line after the exclamation point as a code annotation that can be looked up with the " \ $link ] dip comment-usage.-word 2array " word." 3array $description ]
-    [ ": foo ( x y z -- w )\n    !" " --w-ó()ò-w-- kilroy was here\n    + * ;" surround 1array $unchecked-example ]
+    [ ": foo ( x y z -- w )\n    !" " --w-ó()ò-w-- kilroy was here\n    + * ;" surround 1array $code ]
     tri ;
 
+: <$annotation> ( word -- element )
+    \ $annotation swap 2array 1array ;
+
 : $annotation-usage. ( element -- )
     first
     [ "Displays a list of words, help articles, and vocabularies that contain " \ $link ] dip comment-word 2array " annotations." 3array $description ;
 
+: <$annotation-usage.> ( word -- element )
+    \ $annotation-usage. swap 2array 1array ;
+
 : $annotation-usage ( element -- )
-    first
-    { "usages" sequence } $values
-    [ "Returns a list of words, help articles, and vocabularies that contain " \ $link ] dip [ comment-word 2array " annotations. For a more user-friendly display, use the " \ $link ] [ comment-usage.-word 2array " word." 6 narray ] bi 1array $description ;
+    first [
+        [ "Returns a list of words, help articles, and vocabularies that contain " ] dip
+        [
+            comment-word <$link>
+            " annotations. For a more user-friendly display, use the "
+        ] [
+            comment-usage.-word <$link>
+            " word."
+        ] bi
+    ] output>array $description ;
+
+: <$annotation-usage> ( word -- element )
+    [ { $values { "usages" sequence } } ] dip
+    \ $annotation-usage swap 2array
+    2array ;
 
 "Code annotations"
 {
@@ -42,9 +60,9 @@ annotation-tags natural-sort
 
 annotation-tags [
     {
-        [ [ \ $annotation swap 2array 1array ] [ comment-word set-word-help ] bi ]
-        [ [ \ $annotation-usage swap 2array 1array ] [ comment-usage-word set-word-help ] bi ]
-        [ [ \ $annotation-usage. swap 2array 1array ] [ comment-usage.-word set-word-help ] bi ]
+        [ [ <$annotation> ] [ comment-word set-word-help ] bi ]
+        [ [ <$annotation-usage> ] [ comment-usage-word set-word-help ] bi ]
+        [ [ <$annotation-usage.> ] [ comment-usage.-word set-word-help ] bi ]
         [ [ comment-word ] [ comment-usage-word ] [ comment-usage.-word ] tri 3array related-words ]
     } cleave
 ] each
index 1f4bc3ce7693f0435c41792bf884422eb5b6cf89..497a4bbf62ffc3990178d9943c42798fb169b885 100644 (file)
@@ -1827,14 +1827,13 @@ int
 bignum_unsigned_logbitp(int shift, bignum_type bignum)
 {
   bignum_length_type len = (BIGNUM_LENGTH (bignum));
-  bignum_digit_type digit;
   int index = shift / BIGNUM_DIGIT_LENGTH;
-  int p;
   if (index >= len)
     return 0;
-  digit = (BIGNUM_REF (bignum, index));
-  p = shift % BIGNUM_DIGIT_LENGTH;
-  return digit & (1 << p);
+  bignum_digit_type digit = (BIGNUM_REF (bignum, index));
+  int p = shift % BIGNUM_DIGIT_LENGTH;
+  bignum_digit_type mask = ((F_FIXNUM)1) << p;
+  return (digit & mask) ? 1 : 0;
 }
 
 /* Allocates memory */