View Full Version : Dual precision numbers
05-14-2006, 10:55 AM
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
05-14-2006, 11:41 AM
Here are some double precision math routines which should do the trick, thanks to Dr. Tracy Allen:
05-14-2006, 12:32 PM
Thanks, looks like that will do the trick. -Scott
05-14-2006, 01:10 PM
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
c = 0
for i=0 to 7
c = a + b + c
if c >= 10 then carryIt
a = c : c = 0
a = c - 10: c = 1
05-14-2006, 01:13 PM
Note that the forum software censored my label f.i.n.i.s.h.I.t [ignore the periods].
05-14-2006, 01:15 PM
It also removed my 'i' subscripts after the 'a' and 'b' variables. Oh well!
05-14-2006, 11:02 PM
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").
Applications Engineer, Parallax
05-15-2006, 03:15 AM
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
05-15-2006, 05:37 AM
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