
Caché ObjectScript Reference
$NCONVERT



Server:docs1 
Instance:LATEST 
User:UnknownUser 


Converts a number to a binary value encoded in a string of 8bit characters.
Synopsis
$NCONVERT(n,format,endian)
$NC(n,format,endian)
$NCONVERT uses the specified
format to convert the number
n to an encoded string of 8bit characters. The values of these characters are in the range
$CHAR(0) through
$CHAR(255).
The following are the supported
format codes:
Values beyond the range of
format limits result in a <VALUE OUT OF RANGE> error. Specifying a negative number for an Unsigned
format results in a <VALUE OUT OF RANGE> error. If
n is a nonnumeric value (contains any nonnumeric characters) Caché performs
conversion of a string to a numeric value. A string beginning with a nonnumeric character is converted to 0.
Caché rounds a fractional number to an integer value for all formats except F4 and F8.
You can use the
IsBigEndian() class method to determine which bit ordering is used on your operating system platform: 1=bigendian bit order; 0=littleendian bit order.
WRITE $SYSTEM.Version.IsBigEndian()
The following example converts a series of unsigned numbers to twobyte encoded values:
FOR x=250:1:260 {
ZZDUMP $NCONVERT(x,"U2") }
QUIT
The following example performs the same operation in bigendian order:
FOR x=250:1:260 {
ZZDUMP $NCONVERT(x,"U2",1) }
QUIT