]> gitweb.factorcode.org Git - factor.git/commitdiff
Remove >integer word, clean up some math code
authorslava <slava@factorcode.org>
Thu, 9 Nov 2006 23:09:39 +0000 (23:09 +0000)
committerslava <slava@factorcode.org>
Thu, 9 Nov 2006 23:09:39 +0000 (23:09 +0000)
TODO.FACTOR.txt
library/math/constants.factor
library/math/float.factor
library/math/integer.factor
library/math/math.factor
library/math/pow.factor
library/math/ratio.factor

index b75b660bf5fa290a6267411aea388c93281e9ad1..f035f002bd85710f45d3291eaa632cebc57ce74e 100644 (file)
@@ -1,9 +1,10 @@
-- crypto sig11
+- %allot-bignum-signed-2 is broken on both platforms
+- sometimes fep when closing window
+- windows rollover broken again
 
 + ui:
 
-- sometimes fep when closing window
-- windows rollover broken again
+- dataflow view of [ { array } declare first ] is wrong
 - docs: don't pass volatile aliens to callbacks
 - live search: timer delay would be nice
 - menu should stay up if mouse button released
@@ -41,7 +42,9 @@
 
 + compiler/ffi:
 
-- %allot-bignum-signed-2 is broken on both platforms
+- optimization: if one branch throws an error, then we need to infer
+  types based solely on the other branch
+- cross-word type inference
 - callback scheduling issue
 - amd64 structs-by-value bug
 - intrinsic fixnum>float float>fixnum fixnum>bignum bignum>fixnum
index 33e88ebe790269d07eb75e30bcd037efc70b1d22..03d6e4ecfe56fba4b20013b8c14cf88f07190135 100644 (file)
@@ -26,7 +26,3 @@ IN: math
 
 : most-positive-fixnum ( -- n ) first-bignum 1- ;
 : most-negative-fixnum ( -- n ) first-bignum neg ;
-
-M: float >integer
-    dup most-negative-fixnum most-positive-fixnum between?
-    [ >fixnum ] [ >bignum ] if ;
index 8b8b3a18812eb74531a0072cd42be2d5fc35b9ef..c352849fa747bcb477750f20ac990a26558c528b 100644 (file)
@@ -18,7 +18,8 @@ M: real hashcode >fixnum ;
 M: real <=> - ;
 
 : fp-nan? ( float -- ? )
-    double>bits -51 shift BIN: 111111111111 [ bitand ] keep = ;
+    double>bits -51 shift BIN: 111111111111 [ bitand ] keep
+    number= ;
 
 M: float zero?
     dup 0.0 float= swap -0.0 float= or ;
index 7ec42aff7127667e8011a55087fece798ff799e0..637b6e45398c808d634b90f1379b13b47287bf12 100644 (file)
@@ -6,9 +6,9 @@ sequences-internals ;
 
 UNION: integer fixnum bignum ;
 
-: even? ( n -- ? ) 1 bitand 0 = ;
+: even? ( n -- ? ) 1 bitand zero? ;
 
-: odd? ( n -- ? ) 1 bitand 1 = ;
+: odd? ( n -- ? ) 1 bitand 1 number= ;
 
 : (gcd) ( b a y x -- a d )
     dup zero? [
@@ -17,7 +17,8 @@ UNION: integer fixnum bignum ;
         tuck /mod >r pick * swap >r swapd - r> r> (gcd)
     ] if ; inline
 
-: gcd ( x y -- a d ) 0 1 2swap (gcd) abs ; foldable
+: gcd ( x y -- a d )
+    0 1 2swap (gcd) dup 0 < [ neg ] when ; foldable
 
 : (next-power-of-2) ( i n -- n )
     2dup >= [
@@ -52,8 +53,6 @@ M: integer /
         2dup gcd nip tuck /i >r /i r> fraction>
     ] if ;
 
-M: integer >integer ;
-
 M: fixnum >fixnum ;
 M: fixnum >bignum fixnum>bignum ;
 M: fixnum >float fixnum>float ;
index 10307bd4fd57c1aaae7f30305812e7d4c98865b0..73faccc59654e671ac73ad490c2a6b4d9aaa065b 100644 (file)
@@ -3,7 +3,6 @@
 IN: math
 USING: errors generic kernel math-internals ;
 
-GENERIC: >integer ( x -- y ) foldable
 GENERIC: >fixnum ( x -- y ) foldable
 GENERIC: >bignum ( x -- y ) foldable
 GENERIC: >float ( x -- y ) foldable
index 179ace45e5b0c8ba8b0ca8d83b05aa775bc7c9c4..c98ac91db65b61dccecdc9d87bf81dba2be79242 100644 (file)
@@ -45,7 +45,7 @@ M: integer (^)
 
 : power-of-2? ( n -- ? )
     dup 0 > [
-        dup dup neg bitand =
+        dup dup neg bitand number=
     ] [
         drop f
     ] if ; foldable
@@ -53,6 +53,6 @@ M: integer (^)
 : log2 ( n -- b )
     {
         { [ dup 0 <= ] [ "log2 expects positive inputs" throw ] }
-        { [ dup 1 = ] [ drop 0 ] }
+        { [ dup 1 number= ] [ drop 0 ] }
         { [ t ] [ -1 shift log2 1+ ] }
     } cond ; foldable
index e89f3d87aeace0ae39e8281cdda6efe10167b448..74603cd899c363378700c2372cb73d16e55c7fb7 100644 (file)
@@ -25,10 +25,8 @@ M: ratio number=
 : ratio+d ( a/b c/d -- b*d )
     denominator swap denominator * ; inline
 
-M: ratio >integer >fraction /i ;
-
-M: ratio >fixnum >integer >fixnum ;
-M: ratio >bignum >integer >bignum ;
+M: ratio >fixnum >fraction /i >fixnum ;
+M: ratio >bignum >fraction /i >bignum ;
 
 M: ratio < scale < ;
 M: ratio <= scale <= ;