WordToBin

Syntax:

  stringvar = WordToBin(bytevar)

Command Availability: Available on all microcontrollers.

Explanation:

The WordToBin function creates a string of ANSI characters representing a word’s binary value. It converts a number into a 16-character string consisting of ones and zeros.

Example:

    string = WordToBin(1)       ' Returns "0000000000000001"          ' <<< the WordToBin instruction

    string = WordToBin(37654)   ' Returns "1001001100010110"

Key line: WordToBin(1) — returns the 16-character string "0000000000000001", the binary representation of the word value 1, padded with leading zeros to a fixed width.

See Also:

  • ByteToBin — the equivalent conversion for Byte variables
  • WordToHex — converting a word to hexadecimal instead of binary