From: Leon N. M. <leo...@gm...> - 2010-09-04 19:13:15
|
I've avoided division by reciprocal multiplication because it introduces rounding errors (.1 in decimal is infinitely repeating in binary). That said, we already have some rounding errors, so it may be worth doing -- although these new rounding errors do look slightly more severe. I'll think about it -- the test you can definitely gives me some good information. -Leon On Saturday, September 04, 2010 02:01:30 pm you wrote: > Leon, I did following - I put print"#" in f* and print"%" in f/: > > 987654321. d>f _1e9 f* > > # ok > > > fs. > > %%%%%%%%%%%%%%%%%9.###8###7###6###5###3###6###4E17 ok > > > 987654321. d>f _1e-9 f* > > # ok > > > fs. > > #9.###8###7###6###5###3###2###6E-1 ok > > > 987654321. d>f _1e-9 f/ > > % ok > > > fs. > > %%%%%%%%%%%%%%%%%9.###8###7###6###5###4###5###9E17 ok > > > 987654321. d>f _1e-18 f/ > > % ok > > > fs. > > %%%%%%%%%%%%%%%%%%%%%%%%%%9.###8###7###6###5###5###0###7E26 ok > > > 987654321. d>f _1e-18 f* _1e-12 f* > > ## ok > > > fs. > > ######################9.###8###7###6###4###9###8E-22 ok > > ok > > > 987654321. d>f _1e9 f* _1e12 f* > > ## ok > > > fs. > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%9.###8###7###6###5###3###4###5E29 ok > > So when result with positive exponents E+XX the XX divisions are > made. Therefore I changed the f/ (13ms) with f*(4ms) in the > following routine: > > \ if it's too large, make it smaller > begin > fdup _10 f>= \ [ 10 s>f ] > while > _.1 f* \ _10 f/ \ [ 10 s>f ] <<<<<<<<< Here > fnswap 1+ nfswap > \ ." f>=" > repeat > > So now: > > 987654321. d>f _1e9 f* _1e12 f* > > ## ok > > > fs. > > #############################9.###8###7###6###5###1###2###5E29 ok > > > 987654321. d>f _1e-18 f* _1e-12 f* > > ## ok > > > fs. > > ######################9.###8###7###6###4###9###8E-22 ok > > > So now the conversion with positive exponens (previous f/) i 3x > > faster: > > : measure > > oktimer-start _1 _pi f* _1e15 f* fs. timer-stop fs. ." sec"; > ok > > > measure > > 3.1415874:E15 4.9283066E-1 sec ok > > > : measure > > oktimer-start _1 _pi f* _1e-15 f* fs. timer-stop fs. ." sec"; > ok > > > measure > > 3.1415851E-15 5.4525948E-1 sec ok > > > : measure > > oktimer-start _-1 _pi f* _1e15 f* fs. timer-stop fs. ." sec"; > ok > > > measure > > -3.1415874:E15 4.9283066E-1 sec ok > > > : measure > > oktimer-start _-1 _pi f* _1e-15 f* fs. timer-stop fs. ." sec"; > ok > > > measure > > -3.1415851E-15 5.4525948E-1 sec ok > > So all fs. are now ~0.5sec. > I do not know why the colon in the number (:E15), but probably an > induced bug (:-)). > Pito |