xHarbour Reference Documentation > Function Reference |
Converts a numeric value to an unsigned short binary integer (2 bytes).
W2Bin( <nNumber> ) --> cInteger
The function returns a two-byte character string representing a 16-bit unsigned short binary integer .
W2Bin() is a binary conversion function that converts a numeric value (Valtype()=="N") to a two byte binary number (Valtype()=="C").
The range for the numeric return value is determined by an unsigned short integer. If <nNumber> is outside this range, a runtime error is raised.
See also: | Asc(), Bin2i(), Bin2l(), Bin2u(), Bin2w(), Chr(), I2bin(), L2bin(), U2bin() |
Category: | Binary functions , Conversion functions |
Source: | rtl\binnumx.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates return values of W2Bin(). PROCEDURE Main LOCAL cInt cInt := W2bin(0) ? Asc( cInt[1] ), Asc( cInt[2] ) // result: 0 0 cInt := W2bin(1) ? Asc( cInt[1] ), Asc( cInt[2] ) // result: 1 0 cInt := W2bin(256) ? Asc( cInt[1] ), Asc( cInt[2] ) // result: 0 1 cInt := W2bin(32768) ? Asc( cInt[1] ), Asc( cInt[2] ) // result: 0 128 cInt := W2bin(65535) ? Asc( cInt[1] ), Asc( cInt[2] ) // result: 255 255 RETURN
http://www.xHarbour.com