]> gitweb.factorcode.org Git - factor.git/commitdiff
money: adding support for floats.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 26 Jan 2017 00:44:25 +0000 (16:44 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 26 Jan 2017 00:44:25 +0000 (16:44 -0800)
extra/money/money-tests.factor
extra/money/money.factor

index 66abcb237fdd54fe39132bd35b42ccc8578fad82..786b4828a9ea9edf8cbd44f03f70304d93db1fad 100644 (file)
@@ -23,3 +23,8 @@ IN: money.tests
 
 { "$100.00" } [ DECIMAL: 100.0 money>string ] unit-test
 { "$0.00" } [ DECIMAL: 0.0 money>string ] unit-test
+
+{ "$1.00" } [ 1.0 money>string ] unit-test
+{ "$1.00" } [ 1 money>string ] unit-test
+{ "$1.50" } [ 1+1/2 money>string ] unit-test
+{ "$1.50" } [ 1.50 money>string ] unit-test
index 3e352c88284ee7e3aae0f54f55d0523c88c3c11f..6b54b231a3fb6f74a823a50a69decb82c6f23b71 100644 (file)
@@ -8,7 +8,7 @@ SYMBOL: currency-token
 CHAR: $ currency-token set-global
 
 : dollars/cents ( dollars -- dollars cents )
-    100 * 100 /mod round ;
+    100 * 100 /mod round >integer ;
 
 : format-money ( dollars cents -- string )
     [ number>string ] bi@