]> gitweb.factorcode.org Git - factor.git/blobdiff - core/math/math.factor
use radix literals
[factor.git] / core / math / math.factor
index bc7658feba439629e44aa846561f907db80bd75e..81e488cb19b3fb5c23739b7ccc3411601d79dff0 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2003, 2009 Slava Pestov, Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math.private ;
+USING: kernel ;
 IN: math
 
 GENERIC: >fixnum ( x -- n ) foldable
@@ -59,11 +59,7 @@ PRIVATE>
 ERROR: log2-expects-positive x ;
 
 : log2 ( x -- n )
-    dup 0 <= [
-        log2-expects-positive
-    ] [
-        (log2)
-    ] if ; inline
+    dup 0 <= [ log2-expects-positive ] [ (log2) ] if ; inline
 
 : zero? ( x -- ? ) 0 number= ; inline
 : 2/ ( x -- y ) -1 shift ; inline
@@ -74,15 +70,15 @@ ERROR: log2-expects-positive x ;
 : ?1+ ( x -- y ) [ 1 + ] [ 0 ] if* ; inline
 : rem ( x y -- z ) abs [ mod ] [ + ] [ mod ] tri ; foldable
 : 2^ ( n -- 2^n ) 1 swap shift ; inline
-: even? ( n -- ? ) 1 bitand zero? ;
-: odd? ( n -- ? ) 1 bitand 1 number= ;
+: even? ( n -- ? ) 1 bitand zero? ; inline
+: odd? ( n -- ? ) 1 bitand 1 number= ; inline
 
 : if-zero ( ..a n quot1: ( ..a -- ..b ) quot2: ( ..a n -- ..b ) -- ..b )
     [ dup zero? ] [ [ drop ] prepose ] [ ] tri* if ; inline
 
-: when-zero ( n quot -- ) [ ] if-zero ; inline
+: when-zero ( ..a n quot: ( ..a -- ..b ) -- ..b ) [ ] if-zero ; inline
 
-: unless-zero ( n quot -- ) [ ] swap if-zero ; inline
+: unless-zero ( ..a n quot: ( ..a -- ..b ) -- ..b ) [ ] swap if-zero ; inline
 
 UNION: integer fixnum bignum ;
 
@@ -113,7 +109,7 @@ M: object fp-snan? drop f ; inline
 M: object fp-infinity? drop f ; inline
 
 : <fp-nan> ( payload -- nan )
-    HEX: 7ff0000000000000 bitor bits>double ; inline
+    0x7ff0000000000000 bitor bits>double ; inline
 
 GENERIC: next-float ( m -- n )
 GENERIC: prev-float ( m -- n )