]> gitweb.factorcode.org Git - factor.git/commitdiff
math: make lcm work on real
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 9 Sep 2023 00:59:33 +0000 (17:59 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 9 Sep 2023 00:59:33 +0000 (17:59 -0700)
core/math/math-docs.factor
core/math/math.factor

index e654f9b7aa605089afc339aac2a669a22a033d1c..a1e5562d1fffc0b4ca08189aa822435698b25a7e 100644 (file)
@@ -257,6 +257,7 @@ HELP: lcm
     { $example "USING: math prettyprint ;" "10 8 lcm ." "40" }
     { $example "USING: math prettyprint ;" "10 0 lcm ." "0" }
     { $example "USING: math prettyprint ;" "0 0 lcm ." "0" }
+    { $example "USING: math prettyprint ;" "1/3 1/6 lcm ." "1/3" }
 } ;
 
 HELP: 2/
index 3096af7f68c9e7477a2ee61a86e99139bf8472fa..aeaae13b559e873084499f00cf973cea79c7353d 100644 (file)
@@ -233,7 +233,7 @@ M: bignum simple-gcd bignum-gcd ; inline
 M: real simple-gcd gcd nip ; inline
 
 : lcm ( a b -- c )
-    [ * dup zero? ] 2keep '[ _ _ simple-gcd /i ] unless ; foldable
+    [ * dup zero? ] 2keep '[ _ _ simple-gcd / ] unless ; foldable
 
 : fp-bitwise= ( x y -- ? ) [ double>bits ] same? ; inline