PDA

View Full Version : Dual precision numbers

ScottL
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

Bruce Bates
05-14-2006, 11:41 AM
Scott -

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 -->

ScottL
05-14-2006, 12:32 PM
Thanks, looks like that will do the trick. -Scott

Mike Green
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
goto fini(expletive)
carryIt:
a = c - 10: c = 1
fini(expletive):
next
return

Mike Green
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].

Mike Green
05-14-2006, 01:15 PM
It also removed my 'i' subscripts after the 'a' and 'b' variables. Oh well!

Jon Williams
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").

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

SSteve
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

ScottL
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