Previous Topic Next topic Print topic


BINARY Function

Purpose

Converts an arithmetic or string value to a binary number with an optionally specified precision.

Syntax

BINARY(x[,p])

Abbreviation(s): BIN for BINARY.

Parameters

x is an arithmetic or string value, and p is an integer constant specifying an optional precision.

Description

The BINARY function converts an arithmetic or string value x to binary radix (Float Binary or Fixed Binary data type), with an optionally specified precision p.

If x is a Fixed Decimal value with a non-zero scale factor, p must be given.

If x is a Float Decimal value, the result is a Float Binary value; otherwise, the result is a Fixed Binary value. A non-zero scale factor is not allowed with a Float Decimal. If p is omitted, the result has a precision that is determined by the rules for data type conversion given in the chapter Data Type Conversions.

Examples

BINARY('2000',31);

In fixed–point context, this example returns the value 2000 as a Fixed Bin(31) integer.

Restrictions

None.

Previous Topic Next topic Print topic