Numbers
Lautarocondor
Posts: 15
Hello,
·
This may be a simple problem but it's stumping me. I am trying to program the debug terminal to accept numbers and multiply it by a constant number. It works fine with numbers like 10, 25, 55 and so on, but when I try to use decimals such as 10.2, 25.5 it skips to the answer. Why does this happen and what can I do? I am using the Debug terminal now but plan on using an LCD screen. Also can I use the answer to change the pause time such as: ·Pause (whatever the answer is from the multiplication)?
·
' {$STAMP BS2}
' {$PBASIC 2.5}
·
value1 VAR Word
value2 VAR Word
'value3 VAR Word
·
·
Main:
·DO
Start:
· DEBUG CLS, "Enter Number: "
· DEBUGIN SNUM value1
· value2 = 100
· value1 = value1 * value2
·
· GOTO NXT1
·
NXT1:
·
· DEBUG CLS, SDEC ? value1
·
· PAUSE 3500
·
LOOP
END
·
This may be a simple problem but it's stumping me. I am trying to program the debug terminal to accept numbers and multiply it by a constant number. It works fine with numbers like 10, 25, 55 and so on, but when I try to use decimals such as 10.2, 25.5 it skips to the answer. Why does this happen and what can I do? I am using the Debug terminal now but plan on using an LCD screen. Also can I use the answer to change the pause time such as: ·Pause (whatever the answer is from the multiplication)?
·
' {$STAMP BS2}
' {$PBASIC 2.5}
·
value1 VAR Word
value2 VAR Word
'value3 VAR Word
·
·
Main:
·DO
Start:
· DEBUG CLS, "Enter Number: "
· DEBUGIN SNUM value1
· value2 = 100
· value1 = value1 * value2
·
· GOTO NXT1
·
NXT1:
·
· DEBUG CLS, SDEC ? value1
·
· PAUSE 3500
·
LOOP
END
Comments
The BASIC Stamp (PBASIC) does not directly support floating point values. You must use integers or handle the FP math through code or external hardware, such as the FPU IC we carry. I hope this helps. Take care.
http://www.parallax.com/detail.asp?product_id=604-00030
http://www.parallax.com/detail.asp?product_id=604-00050
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
D Faust