xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Bin2I()

Converts a signed short binary integer (2 bytes) into a numeric value.

Syntax

Bin2I( <cInteger> ) --> nNumber

Arguments

<cInteger>
This is a character string whose first two bytes are converted to a 16 bit signed integer value of numeric data type.

Return

The function returns a numeric value in the range of -(2ˆ15) to +(2ˆ15) - 1.

Description

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.

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe