Floating decimal point
dragonvet
Posts: 17
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
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
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.