diff --git a/core/math/floats/floats.factor b/core/math/floats/floats.factor index 47ecdab125..3fa9be4cad 100644 --- a/core/math/floats/floats.factor +++ b/core/math/floats/floats.factor @@ -38,6 +38,8 @@ M: float /i float/f >integer ; inline M: real abs dup 0 < [ neg ] when ; inline +M: real /mod [ /i ] [ mod ] 2bi ; inline + M: float fp-special? double>bits -52 shift 0x7ff [ bitand ] keep = ; inline diff --git a/core/math/math-docs.factor b/core/math/math-docs.factor index a3d252495d..b673a02b70 100644 --- a/core/math/math-docs.factor +++ b/core/math/math-docs.factor @@ -133,7 +133,7 @@ HELP: mod { $see-also "division-by-zero" rem } ; HELP: /mod -{ $values { "x" integer } { "y" integer } { "z" integer } { "w" integer } } +{ $values { "x" real } { "y" real } { "z" integer } { "w" real } } { $description "Computes the quotient " { $snippet "z" } " and remainder " { $snippet "w" } " of dividing " { $snippet "x" } " by " { $snippet "y" } ", with the remainder being negative if " { $snippet "x" } " is negative." { $list @@ -141,6 +141,10 @@ HELP: /mod "The quotient and remainder of two bignums is always a bignum." } } +{ $examples + { $example "USING: kernel math prettyprint ;" "5 3 /mod [ . ] bi@" "1\n2" } + { $example "USING: kernel math prettyprint ;" "5/2 1/3 /mod [ . ] bi@" "7\n1/6" } +} { $see-also "division-by-zero" } ; HELP: bitand