Sujet : Re: exercise in double number arithmetic
De : melahi_ahmed (at) *nospam* yahoo.fr (Ahmed)
Groupes : comp.lang.forthDate : 07. Jul 2024, 22:41:27
Autres entêtes
Organisation : novaBBS
Message-ID : <c3223a1276734e391fcacfd630f5db2b@www.novabbs.com>
References : 1 2 3 4 5 6 7
User-Agent : Rocksolid Light
On Sun, 7 Jul 2024 20:52:43 (UTC), mhx wrote:
..
>
FORTH> 131 dup 2/ chs cr ud.
188694833082770476622296176145946360850
( correct cf. WolframAlpha, but 132 66 CHS is incorrect )
>
-marcel
Same results when using ud. instead of d.
200 value M
create coeffs 2 M * 2* cells allot
: coeffs.init
coeffs 2 M * 2* cells erase
2 0 do 1. coeffs i M * 2* cells + 2! loop ;
0 value k
0 value n
: coef.calc { n k -- }
\ to k to n
coeffs.init
n 1+ 1 do
k 1+ 1 do
coeffs j 1- 2 mod M * i 1- + 2* cells + 2@
coeffs j 1- 2 mod M * i + 2* cells + 2@
d+
coeffs j 2 mod M * i + 2* cells + 2!
loop
loop
coeffs n 2 mod M * k + 2* cells + 2@ ud.
;
131 65 coef.calc 188694833082770476622296176145946360850 ok (correct)
132 66 coef.calc 37107299244602489781217744860124510244 ok (incorrect)
Ahmed