IntegerToBin

Syntax:

    stringvar = IntegerToBin(integervar)

Command Availability:

Available on all microcontrollers.

Explanation:

The IntegerToBin function creates a signed, 16-character string representing an Integer’s binary value: a leading + or - sign followed by 15 binary digits.

Note: Supports Integer variables only. For Byte variables use ByteToBin, for Word variables use WordToBin, and for Long variables use LongToBin.

Example:

    string = IntegerToBin( 1 )   ' Returns "+000000000000001"          ' <<< the IntegerToBin instruction
    string = IntegerToBin( -1 )  ' Returns "-000000000000001"

Key line: IntegerToBin( -1 ) — returns a string that keeps the sign character separate from the 15 magnitude digits, so the sign is always in the same position regardless of the value.

See Also: