
Originally Posted by
Bruce
You can do the same thing without DIG.
Code:
Main:
H=37234
'fill divisor with digits 0 to 4 from H
FOR b = 0 to 4
divisor[b] = H//10
H=H/10
NEXT b
GOTO Main
As a learning exercise, see if you can figure out why this works the same as DIG - or come
up with another method...;o}
Ok, Bruce you are also a teacher 
As earlier said, I did not remember the DIG statement and obviously not modulus divider "//" neither.
That piece of code is clear and surely should work, however, if wouldn't work as expected then again there would be something to marvel over
But fortunately that is not the case....
So if we compare the "original" and your excellent DIG interpreter:
Code:
a)
FOR b = 0 to 4
gosub powerTen
divisor [b] = (H/w) & $0f
next b
b)
FOR b = 0 to 4
divisor[b] = H//10
H=H/10
NEXT b
Still wondering what is wrong in a?
If we convert those code fragments to algorithms then them would be something like this:
a) divide H with power of ten (10^n, when goes n=0..4) to get rid of the decimals, isolate the lsd and store it. Do it five times.
b) isolate the lsd with H mod 10, store it and truncate H with one digit. Do it five times. Simple and clear algorithm....
I just don't grasp what is wrong with a, I do not need it anymore, just wondering
Bookmarks