| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Converts a signed short binary integer (2 bytes) into a numeric value.
Bin2I( <cInteger> ) --> nNumber
The function returns a numeric value in the range of -(2ˆ15) to +(2ˆ15) - 1.
Bin2I() is a binary conversion function that converts a two byte binary number (Valtype()=="C") to a numeric value (Valtype()=="N"). The parameter <cInteger> is usually the return value of function I2Bin().
The range for the numeric return value is determined by a signed short integer.
| See also: | Bin2L(), Bin2U(), Bin2W(), FRead(), I2Bin(), L2Bin(), U2Bin(), W2Bin(), Word() |
| Category: | Binary functions , Conversion functions |
| Source: | rtl\binnum.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example demonstrates encoding of binary signed 16 bit integer
// numbers and their conversion to numeric values.
PROCEDURE Main
? Bin2I( Chr(0) + Chr(0) ) // result: 0
? Bin2I( Chr(1) + Chr(0) ) // result: 1
? Bin2I( Chr(255) + Chr(255) ) // result: -1
? Bin2I( Chr(0) + Chr(1) ) // result: 256
? Bin2I( Chr(0) + Chr(255) ) // result: -256
? Bin2I( Chr(255) + Chr(127) ) // result: 32767
? Bin2I( Chr(0) + Chr(128) ) // result: -32768
RETURN
http://www.xHarbour.com