09-11-2022, 02:31 AM
(09-11-2022, 01:48 AM)Pete Wrote: I kept a beta version of it that prints out what it is doing. I'm thinking I might post it in a new discussion thread on string math division. Basically what I did was to shortcut zero and 1 divisors, chop out leading zeros in small decimal numbers making less digits to calculate, estimate the mult loop by using just the first one or two digits of the divisor and the dividend or remainder so it usually only takes two tries to get the right multiplier before subtracting to obtain the remainder and, of course, working with chunks of numbers with multiplication and subtraction in the long division process.@Pete Hmm, that sounds pretty straight-forward! I was gunna try that next!
I knew it would be faster, I'm just amazed it's so much faster.
Now I'm wondering how much faster it could be if I switched from string concatenation to fixed string replacement? I did that once with a c keyboard WP routine (about the only complicated C/C++ prog I've ever written) and the speed increase was pretty impressive. Converting for string math might be a bit of a challenge, and if too many conditions need to be added, it might end up being a push.
The only miss I had on this new routine was the bloat of about 40 more lines than my previous division code. I really wanted to do this one in about the same number of lines but no dice. In contrast, I think I cut code in both the multiplication and add/subtract routines.
Thanks,
Pete
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/
Please visit my Website at: http://oldendayskids.blogspot.com/