Shop OBEX P1 Docs P2 Docs Learn Events
Numbers — Parallax Forums

Numbers

LautarocondorLautarocondor Posts: 15
edited 2007-07-15 01:24 in BASIC Stamp
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

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-07-14 20:39
    Hello,

    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 FaustD Faust Posts: 608
    edited 2007-07-14 23:41
    Couldn't you also just move the decimal point over before inputting the number.· In your example you could·move the decimal point one space to the right and just multiply by 10.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    D Faust
  • LautarocondorLautarocondor Posts: 15
    edited 2007-07-15 01:24
    The idea of the debug interface is to allow me to enter lengths in millimeters and have the Stamp control a stepper motor with rollers to feed ribbon cables and cut it with a pneumatic cutter. It needs to go up to 1219.20 millimeters.
Sign In or Register to comment.