I'm using Gforth, and I've looked for a standard Forth word for dividing two double integers, or at least a mixed division of a double integer by a single integer, yet supporting double integers as a result. There doesn't seem to be one. SM/REM
, FM/MOD
and UM/MOD
have all limitations.
Did I miss anything? Why wouldn't such a word already come built-in with Forth? The operation is well-defined and no arithmetic overflows can happen. Is it necessary to program it myself?
M*/ (d n u -- result)
may be the word you're looking for. From Starting Forth (the original print version):
Multiplies a 32-bit number by a 16-bit number and divides the triple-length result by a 16-bit number (d*n/u). Returns a 32-bit result. All values are signed.
So to divide a double by a single, you could subtitute n for 1. Included in DPANS94, "The optional Double-Number word set".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With