Shop OBEX P1 Docs P2 Docs Learn Events
simple question on serial terminals — Parallax Forums

simple question on serial terminals

sticktradersticktrader Posts: 15
edited 2010-07-22 16:27 in Propeller 1
I have a quick question about decimal numbers being transfered serially.· If I use the "Parallax Serial Terminal" spin code and I use the "Float 32" spin code and I want to add to decimal numbers together.· The numbers being decimal fractions like 5.5 and 2.5, how do I get it to do it by changing the above numbers into floating point numbers.· When I try to use DecIn it changes the numbers into intergers and ignores the decimal place.· I am assuming I make them a string and send them to the program but then I cannot add them without changing them into a floating point number somehow.

Thanks

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2010-07-22 05:27
    integernumbers can be pretty big on the propeller (+- 2.147.483.648)

    So if your numbers are not too big - simply multiply them with 10 or 100 or how many digits you have after the fractionpoint and then simply add the integervalues

    in your example above this would mean

    5.5 * 10 = 55
    2.5 * 10 = 25

    55 + 25 = 70

    If this solution does not work you have to provide more information about your project that the forum-members know
    the limitations of your project

    best regards

    Stefan
  • sticktradersticktrader Posts: 15
    edited 2010-07-22 16:27
    That works but I didn't know if there was an already written code to address this situation or possibly a spin·keyword I was missing.

    Thanks
Sign In or Register to comment.