Shop OBEX P1 Docs P2 Docs Learn Events
Dual precision numbers — Parallax Forums

Dual precision numbers

ScottLScottL Posts: 14
edited 2006-05-14 21:37 in BASIC Stamp
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

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-05-14 03:41
    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 -->
  • ScottLScottL Posts: 14
    edited 2006-05-14 04:32
    Thanks, looks like that will do the trick. -Scott
  • Mike GreenMike Green Posts: 23,101
    edited 2006-05-14 05:10
    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
  • Mike GreenMike Green Posts: 23,101
    edited 2006-05-14 05:13
    Note that the forum software censored my label f.i.n.i.s.h.I.t [noparse][[/noparse]ignore the periods].
  • Mike GreenMike Green Posts: 23,101
    edited 2006-05-14 05:15
    It also removed my 'i' subscripts after the 'a' and 'b' variables. Oh well!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-14 15:02
    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
  • SSteveSSteve Posts: 808
    edited 2006-05-14 19:15
    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
  • ScottLScottL Posts: 14
    edited 2006-05-14 21:37
    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
Sign In or Register to comment.