math: implement /mod on floats.
parent
4d9d980e22
commit
9620438ab7
|
@ -38,6 +38,8 @@ M: float /i float/f >integer ; inline
|
||||||
|
|
||||||
M: real abs dup 0 < [ neg ] when ; inline
|
M: real abs dup 0 < [ neg ] when ; inline
|
||||||
|
|
||||||
|
M: real /mod [ /i ] [ mod ] 2bi ; inline
|
||||||
|
|
||||||
M: float fp-special?
|
M: float fp-special?
|
||||||
double>bits -52 shift 0x7ff [ bitand ] keep = ; inline
|
double>bits -52 shift 0x7ff [ bitand ] keep = ; inline
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ HELP: mod
|
||||||
{ $see-also "division-by-zero" rem } ;
|
{ $see-also "division-by-zero" rem } ;
|
||||||
|
|
||||||
HELP: /mod
|
HELP: /mod
|
||||||
{ $values { "x" integer } { "y" integer } { "z" integer } { "w" integer } }
|
{ $values { "x" real } { "y" real } { "z" integer } { "w" real } }
|
||||||
{ $description
|
{ $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."
|
"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
|
{ $list
|
||||||
|
@ -141,6 +141,10 @@ HELP: /mod
|
||||||
"The quotient and remainder of two bignums is always a bignum."
|
"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" } ;
|
{ $see-also "division-by-zero" } ;
|
||||||
|
|
||||||
HELP: bitand
|
HELP: bitand
|
||||||
|
|
Loading…
Reference in New Issue