]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/math/functions/functions.factor
use radix literals
[factor.git] / basis / math / functions / functions.factor
index 241261e3bf35692b45f7de5cd115420f05bf37f3..f1e68c9f86efd6ddc00aac19d8bd8f1898725900 100644 (file)
@@ -96,9 +96,6 @@ M: complex exp >rect [ exp ] dip polar> ; inline
         swap [ /mod [ over * swapd - ] dip ] keep (gcd)
     ] if ; inline recursive
 
-: (gcd*) ( a b -- c )
-    [ [ mod ] keep swap (gcd*) ] unless-zero ; inline recursive
-
 PRIVATE>
 
 : ^ ( x y -- z )
@@ -112,16 +109,13 @@ PRIVATE>
 : nth-root ( n x -- y ) swap recip ^ ; inline
 
 : gcd ( x y -- a d )
-    [ 0 1 ] 2dip (gcd) dup 0 < [ neg ] when ; foldable
-
-: gcd* ( x y -- d )
-    (gcd*) dup 0 < [ neg ] when ; foldable
+    [ 0 1 ] 2dip (gcd) dup 0 < [ neg ] when ; inline
 
 : lcm ( a b -- c )
-    [ * ] 2keep gcd* /i ; foldable
+    [ * ] 2keep gcd nip /i ; foldable
 
 : divisor? ( m n -- ? )
-    mod 0 = ;
+    mod 0 = ; inline
 
 ERROR: non-trivial-divisor n ;
 
@@ -166,14 +160,14 @@ GENERIC: frexp ( x -- y exp )
 M: float frexp
     dup fp-special? [ dup zero? ] unless* [ 0 ] [
         double>bits
-        [ HEX: 800f,ffff,ffff,ffff bitand 0.5 double>bits bitor bits>double ]
-        [ -52 shift HEX: 7ff bitand 1022 - ] bi
+        [ 0x800f,ffff,ffff,ffff bitand 0.5 double>bits bitor bits>double ]
+        [ -52 shift 0x7ff bitand 1022 - ] bi
     ] if ; inline
 
 M: integer frexp
     [ 0.0 0 ] [
         dup 0 > [ 1 ] [ abs -1 ] if swap dup log2 [
-            52 swap - shift HEX: 000f,ffff,ffff,ffff bitand
+            52 swap - shift 0x000f,ffff,ffff,ffff bitand
             0.5 double>bits bitor bits>double
         ] [ 1 + ] bi [ * ] dip
     ] if-zero ; inline
@@ -189,11 +183,11 @@ M: complex log >polar [ flog ] dip rect> ; inline
 <PRIVATE
 
 : most-negative-finite-float ( -- x )
-    HEX: -1.ffff,ffff,ffff,fp1023 >integer ; inline
+    -0x1.ffff,ffff,ffff,fp1023 >integer ; inline
 : most-positive-finite-float ( -- x )
-    HEX:  1.ffff,ffff,ffff,fp1023 >integer ; inline
-CONSTANT: log-2   HEX: 1.62e42fefa39efp-1
-CONSTANT: log10-2 HEX: 1.34413509f79ffp-2
+    0x1.ffff,ffff,ffff,fp1023 >integer ; inline
+CONSTANT: log-2   0x1.62e42fefa39efp-1
+CONSTANT: log10-2 0x1.34413509f79ffp-2
 
 : (representable-as-float?) ( x -- ? )
     most-negative-finite-float