]> gitweb.factorcode.org Git - factor.git/commitdiff
math.functions: fix divisor? to work with mixed numbers
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 7 Jan 2024 01:52:36 +0000 (17:52 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 7 Jan 2024 01:52:36 +0000 (17:52 -0800)
basis/math/functions/functions-tests.factor
basis/math/functions/functions.factor

index 906264e5e25890c2729a6c384502baddf166c5ba..c7fe48545ba397d2c258348e2d412b6d92f9f59f 100644 (file)
@@ -159,6 +159,7 @@ CONSTANT: log10-factorial-1000 0x1.40f3593ed6f8ep11
 { t } [ 42 -7 divisor? ] unit-test
 { t } [ 42 42 divisor? ] unit-test
 { f } [ 42 16 divisor? ] unit-test
+{ t } [ 42.0 1 divisor? ] unit-test
 
 { 3 } [ 5 7 mod-inv ] unit-test
 { 78572682077 } [ 234829342 342389423843 mod-inv ] unit-test
index c9cb435197633ce5fcdfdcab89751a018f143d7c..d691fb9f747a01b7d48c31465566ca45dc732a7a 100644 (file)
@@ -106,8 +106,7 @@ PRIVATE>
 
 : nth-root ( n x -- y ) swap recip ^ ; inline
 
-: divisor? ( m n -- ? )
-    mod 0 = ; inline
+: divisor? ( m n -- ? ) mod zero? ; inline
 
 ERROR: non-trivial-divisor n ;