Liste des Groupes | Revenir à cl forth |
On 10/07/2024 6:41 pm, dxf wrote:This is interesting. I had recently implemented the non-standard word UD/MOD based on the corresponding word in Gforth. Thus, I have the double length division words,On 10/07/2024 5:51 pm, Gerry Jackson wrote:Here's one I had lying around. Not sure if I used it so may require checking>Here's the source file (32MATH.SEQ) for those interested:
[...] I found I had another definition for D/MOD from Forth Dimensions Vol 14 Issue 6, p 27 "Math - Who Needs It"
https://www.forth.org/fd/FD-V14N6.pdf
I've no idea how good it is
>
https://pastebin.com/mfU8FZ1x
first! The 2variable is an eye-sore. Perhaps someone can eliminate it without
resorting to locals :)
2variable d
\ Divide quad by double. Unsigned.
: DUM/MOD ( uq ud -- udrem udquot )
d 2! [ 16 cells ] literal 0 do
dup >r 2swap dup >r d2* 2swap d2*
r> 0< dup d- 2dup d 2@ du< 0= r> 0< or
if d 2@ d- 2swap 1 0 d+ 2swap then
loop 2swap ;
\ Divide doubles. Unsigned.
: DU/MOD ( ud1 ud2 -- udrem udquot )
0 0 2swap dum/mod ;
\ Divide doubles. Signed. Symmetric.
: D/MOD ( d1 d2 -- drem dquot )
2 pick 2dup xor 2>r dabs 2swap dabs
2swap du/mod r> 0< if dnegate then
r> 0< if 2swap dnegate 2swap then ;
Les messages affichés proviennent d'usenet.