BIN

Synopsis

HELP:   Integer in binary format
TYPE:   OBJECT
SYNTAX: BIN(SIGNED,ENDIAN=SYSTEM/BIG/LITTLE/LOCAL,WIDTH=num/W08/W16/W32/W64)

Description

Writes a binary representation of an integer number, taking an FL5-internal neutral integer representation (produced by the reading counterpart) as input.

This converter supports the most common binary number sizes: 8, 16, 32 and 64 bit. Hence, the output of this converter is either 1, 2, 4 or 8 bytes long.

The desired binary integer width can be specified in two ways:

  1. Setting the WIDTH parameter to one of the supported bit widths results in binary integers of the specified width. If the number cannot be represented as a binary integer of this width, a range error occurs.
  2. If the WIDTH parameter is omitted, the buffer given to the writer must be 1, 2, 4 or 8 bytes long and is filled with a binary integer of the corresponding width. This allows using one converter handle to convert to binary of different bit widths, when using the byte interface (fcbconv()), by simply passing output buffers of different sizes. If the number cannot be represented as binary integer of the given width, a range error occurs.

If the SIGNED flag is set, the binary number is written as a two's complement binary number, which can be negative. Otherwise, the output is an unsigned number. Attempting to convert a negative number to an unsigned binary integer results in a range error.

With the ENDIAN parameter, the endianness (byte order) of the binary number can be specified. By default, the system's endianness is used.

Arguments