assigning a value to a variable or constant?
wperko
Posts: 66
Hi,
ibyte = 768
Why does the result of;
DEBUG CR, "ibyte = ", DEC ibyte, CR
give ibyte = 108 ???
What is going wrong here?
ibyte = 768
Why does the result of;
DEBUG CR, "ibyte = ", DEC ibyte, CR
give ibyte = 108 ???
What is going wrong here?
Comments
' ByteParse4.bs2
' {$STAMP BS2}
' {$PBASIC 2.5}
' Initialze
'
' Variables
'
ibyte VAR Byte ' byte to be converted
hbyte VAR Byte ' bytes to represent Hundreds digit
mbyte VAR Byte ' bytes to represent Tens digit
lbyte VAR Byte ' bytes to represent Ones digit
Remainder VAR Byte
' Initialize ibyte
ibyte = 876 ' initial byte to be converted to 3 values
DEBUG CR, CR, "ibyte = ", DEC ibyte, CR, CR
hbyte = ibyte DIG 2
mbyte = ibyte DIG 1
lbyte = ibyte DIG 0
DEBUG CR, "hbyte = ", DEC hbyte, CR
DEBUG CR, "mbyte = ", DEC mbyte, CR
DEBUG CR, "lbyte = ", DEC lbyte, CR, CR, CR
END
As Mike said, if you are declaring ibyte as a BYTE, it can only represent a number up to 255.
Try:
ibyte VAR Word
and see the magic happen.