Convert Numeric Sign

ByteToInt16(), WordToInt16(), ByteToInt32(), WordToInt32()

Converts the source value into a signed one. This function is reuired if you want to pass on a unsigned variable or return value. Example is converting a Byte function result (0-255) that you want to use as a signed value (-127… +128). Byte is a unsigned data type, so all subsequent calculations would also be unsigned.

Syntax

Example:

const F_CPU=20000000
avr.device = atmega328p
avr.clock  = F_CPU
avr.stack = 64
uart.baud = 19200
uart.recv.enable
uart.send.enable
dim a as byte
dim b as word
a=0xff
b=0xffff
print str(a)                'Output: "255"
print str(b)                'Output: "65535"
print str(ByteToInt16(a))   'Output: "-1"
print str(WordToInt16(b))   'Output: "-1"