Using SDEC with DEBUG
basicstampede
Posts: 214
' {$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.
' {$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
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
·
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?
Newzed@aol.com
·