I need to store floating point ascii data * 10 in a sword variable, but REAL modifier work only for OUTPUT.
String format of sensor is XXX.X can be :
String = “18.7” I need store Var = 187
String = “0.4” I need store Var = 4
String = “-0.5” I need store Var = -5
String = “-36.0” I need store Var = -360
My code work only for POSITIVE value:(
'input is 10.5
serin pin, baud, [dec int, dec flo]
output = int * 10 + flo
'output is 105, work.
I can’t test “int” because I lost sign for -0.xxxx
DEC is for UNSIGNED values
SDEC if for signed values.
Ie. DEC will ignorethe “-” character.
If you send a “-123” DEC will only see “123”.
SDEC sees “-” characters so if you send “-123” it will see “-123” and return a -123. Note you MUST use signed variables with sdec for it to work correctly.
For example, if you send a “-1” to SDEC but the variable for SDEC is a WORD(instead of an SWORD) your variable will hold 65535 instead of -1.