Shop OBEX P1 Docs P2 Docs Learn Events
Using SDEC with DEBUG — Parallax Forums

Using SDEC with DEBUG

basicstampedebasicstampede Posts: 214
edited 2007-01-19 14:17 in BASIC Stamp
' {$STAMP BS2}
' {$PBASIC 2.5}

number VAR Byte(10)
number(9) = 0
i VAR Word
FOR i=0 TO 8
DEBUG "Enter a number", CR
DEBUGIN SDEC number(i)
NEXT
FOR i=0 TO 8
DEBUG "number(", DEC i, ") is ", SDEC number(i), " in SDEC format", CR
NEXT

END

For the numbers, I entered -1, -2, -3, ...-9.
I was expecting to see the same negative numbers shown with last debug statement.
However, it gave instead 255, 254, 253,...248.

I want to see the negative number I typed.·

What is my mistake in coding?

Thanks.

Comments

  • NewzedNewzed Posts: 2,503
    edited 2007-01-19 14:14
    Change

    DEBUG "number(", DEC i, ") is ", SDEC number(i), " in SDEC format", CR

    to

    DEBUG "number(", DEC i, ") is ", SDEC number(i)-256, " in SDEC format", CR

    and see what happens.· Also. change the SDEC in debugin to DEC.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Don't have VGA?

    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2007-01-19 14:17
    Correction:· Leave the SDEC in DEBUGIN.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Don't have VGA?

    Newzed@aol.com
    ·
Sign In or Register to comment.