I'm eating words for dinner tonight

6 views
Skip to first unread message

The Beez

unread,
Apr 7, 2026, 12:04:26 PM (2 days ago) Apr 7
to 4tH-compiler
Hi 4tH-ers!

Every now and then you got to eat your words. That's how it is. You know I was busy doing arbitrary precision arithmetic, and there was one word left to build.

Now this thing had two DO..LOOP loops - which is not the thing you want in an OOP program - and three objects, the object itself, the object dropped as a parameter and another object, which was created to store the result. And no, we're not counting the transient stuff.

So - that's four items on the stack and minimum three on the data stack. That's a full house. Nowhere to hide.

Of course I used STACKOPT.4TH to come up with solutions - and it did. But it was an awful mess. I spend a whole evening trying to debug the thing - to no avail. So I tried variables.

And yes, I got the whole thing running in no time. It's even readable! Another thing - I used my recent FOR..NEXT definition for the loops, so it was easier to replicate the C++ for() loop (which contained a check on the carry).

This means you can now multiply two arbitrary precision numbers - if you need to do so. I don't have a solution for division yet. May be later. Note that the current solution is weird - a strange mixture of FOOS Forth and ordinary Forth - but it works fine when used as a static APN method. I can do that. I know how things work under the hood ;-)

Code in SVN.

Hans Bezemer
Reply all
Reply to author
Forward
0 new messages