Shop OBEX P1 Docs P2 Docs Learn Events
Floating decimal point — Parallax Forums

Floating decimal point

dragonvetdragonvet Posts: 17
edited 2009-08-17 01:59 in Propeller 1
Wondering how to preserve a decimal point in a number string when using FullDuplexSerial and Parallax Serial Terminal.
For instance when using "EnterandDisplayValue" object from the labs, when I enter in a value like 147.54 the display says
"You have entered'
14754
I can not figure out the floating point decimal methods from the PE kit
anyone help?
Thanks,
Rich

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-16 17:26
    "EnterandDisplayValue" doesn't use floating point. It uses integer only. If you enter anything other than a digit or minus sign, it gets ignored.

    I think the only demo program that actually uses floating point is "FloatingStringTest" and that only does addition and output of a floating point value.

    You need to remember that Spin has very little support of floating point. It allows you to write floating point constants and constant expressions, but there are no floating point type variables and all floating point operations are done by function calls. The built-in operators (like "+", "-", "*", "/") are integer only. If you write "A := 1.26" and then write "A := A + 2.34" you will get some kind of meaningless value that's the result of adding the internal floating point representations of the two numbers together as integers.

    Download the floating point library from the Object Exchange. That archive includes the documentation which shows how to use it.
  • dragonvetdragonvet Posts: 17
    edited 2009-08-17 01:59
    Thanks
Sign In or Register to comment.