$Binary

From m204wiki
(Redirected from $BINARY)
Jump to navigation Jump to search

The $Binary function converts the character string representation of a number into its equivalent fixed-point binary representation.

Syntax

The format of the $Binary function is:

$Binary (string [, precision [, scale]])

where:

  • string is the character string to be converted.
  • precision (optional) indicates the number of binary digits (bits) desired in the result of the function. Precision must be between 1 and 31, although the most meaningful values are 15 and 31. If the precision argument is greater than 15, a default value of 31 is used. If the precision argument is omitted, a default value of 15 (halfword) is used.
  • scale (optional) indicates the number of fractional binary digits assumed in the result of the function. If the scale argument is omitted, a default value of 0 (integer) is used.

$Binary returns a value of binary -1 if the string argument does not represent a valid number, if an invalid precision or scale value is specified, or if an overflow occurs.