xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Bin2L()

Converts a signed long binary integer (4 bytes) into a numeric value.

Syntax

Bin2L( <cInteger> ) --> nNumber

Arguments

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

Return

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

Description

Bin2L() is a binary conversion function that converts a four byte binary number (Valtype()=="C") to a numeric value (Valtype()=="N"). The parameter <cInteger> is usually the return value of function L2Bin().

The range for the numeric return value is determined by a signed long integer.

Info

See also:Bin2I(), 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 32 bit integer
// numbers and their conversion to numeric values.

   PROCEDURE Main
      ? Bin2L(   Chr(0) +   Chr(0) +   Chr(0) +   Chr(0) )  // result:           0

      ? Bin2L(   Chr(1) +   Chr(0) +   Chr(0) +   Chr(0) )  // result:           1
      ? Bin2L( Chr(255) + Chr(255) + Chr(255) + Chr(255) )  // result:          -1

      ? Bin2L(   Chr(0) +   Chr(1) +   Chr(0) +   Chr(0) )  // result:         256
      ? Bin2L(   Chr(0) + Chr(255) + Chr(255) + Chr(255) )  // result:        -256

      ? Bin2L( Chr(255) + Chr(255) + Chr(255) + Chr(127) )  // result:  2147483647
      ? Bin2L(   Chr(0) +   Chr(0) +   Chr(0) + Chr(128) )  // result: -2147483648
   RETURN

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