I have an application where I need to display a decimal number greater than 65535. (word) Does anyone have an idea of how to collect numbers greater than 65535 and display them using LCDOUT?· -Scott
If you mostly need to input and output or count or add, you could do binary coded decimal (BCD) with a decimal digit per nibble. The Stamp can access nibbles (4 bits) as arrays storing two decimal digits per byte. A simple loop could add two 8 digit numbers one digit at a time like:
a var nib(8)
b var nib(8)
c var byte
i var nib
add:
c = 0
for i=0 to 7
c = a + b + c
if c >= 10 then carryIt
a = c : c = 0
goto fini(expletive)
carryIt:
a = c - 10: c = 1
fini(expletive):
next
return
We've had some unruly teenagers attempting to post foul language in recent months so we've had to enable auditing for "naughty" keywords -- I think Finish_It would have flown through and looks like a valid label (in accordance with "The Elements of PBASIC Style").
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams Applications Engineer, Parallax
And you would have had better luck with the subscripts if you had enclosed the code in a code tag. Outside of the code tag the i in square brackets turns italics on. That's why some of the code is italicized.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ OS-X: because making Unix user-friendly was easier than debugging Windows
Mike, thanks for the BCD idea. Unfortunately I could not follow your example but I was able to take the idea and make it work. (though not efficiently) -Scott
Comments
Here are some double precision math routines which should do the trick, thanks to Dr. Tracy Allen:
http://www.emesystems.com/BS2math6.htm
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
a var nib(8)
b var nib(8)
c var byte
i var nib
add:
c = 0
for i=0 to 7
c = a + b + c
if c >= 10 then carryIt
a = c : c = 0
goto fini(expletive)
carryIt:
a = c - 10: c = 1
fini(expletive):
next
return
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows