From: Kalus M. <mic...@on...> - 2008-07-17 18:34:10
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. Am 17.07.2008 um 16:44 schrieb Matthias Trute: >> In dpans forth there is no "u*/mod" at all; even gforth has no such >> word. >> >> I wonder how it sneeked into amforth? > > Good question, and I do not find the test case anymore in my > unchanged core.frt file... Must have been something where an unsigned double precision intermediate calculation has been nessesary (= mixed precision arithmetic) Mixed precision means you take 2 unsigned single precision integers, multiply into double precision so you dont loose the overflow if it happens to have one, then calculate division and remainder using this double precision intermediate result. If you do it with * and /mod you get wrong results when overflow of the product ocures. (Thats why there is no u* or u/mod to get mixed up with.) So, instead of creating an extra *core* word named u*/mod I think its more clean programming to use um* and um/mod inline instead. um* ( u1 u2 – ud) \ core “u-m-star” um/mod ( ud u3 – u4 u5) \ core “u-m-slash-mod” The inlined phrase ( u1 u2 u3 – u4 u5 ) >r um* r> um/mod should work as well and you can see what happens and test it. Further more as u*/mod is not standard (as far as I can see) you loose portability of code. And as it is not coded in assembler but in high level, I can not see any speed benefit. As it comes along whit another level of nesting, it slows down calculaton a littel bit instead. > Sorry about the confusion, I'll change the code as suggested I vote for dropping it or move it into, hm, maybe lib/misc.frt ? (Yes, I like amforth to be as lean as possible to meet standards. Is it getting too fat and needs review? ;-) Michael -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFIf5CWJ3DLQCvSXtcRAszuAJ9b9EXOII8L89KDdjXkXIYF/KCDUQCeN0mI hn2c7eRpFsIFRkMand3oSvI= =ZiD/ -----END PGP SIGNATURE----- |