$FACTOR (ObjectScript)
Synopsis
$FACTOR(num,scale)
Arguments
Argument | Description |
---|---|
num | An expression that evaluates to a number. num is converted to a positive integer before bitstring conversion. A negative number is converted to a positive number (its absolute value). A fractional number is rounded to an integer. |
scale | Optional — An integer used as a power-of-ten exponent (scientific notation) multiplier for num. The default is 0. |
Description
$FACTOR returns the $BIT format bitstring that corresponds to the binary representation of the supplied integer. It performs the following operations:
-
If you specify a negative number, $FACTOR takes the absolute value of the number.
-
If you specify a scale $FACTOR multiplies the integer by 10**scale.
-
If you specify a fractional number $FACTOR rounds this number to an integer. When rounding numbers, InterSystems IRIS rounds the fraction .5 up to the next highest integer.
-
$FACTOR converts the integer to its binary representation.
-
$FACTOR converts this binary number to $BIT encoded binary format.
The binary string returned specifies bit positions starting from the least significant bit at position 1 (one's place at position 1). This corresponds to the bitstrings used by the various $BIT functions.