xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

L2bin()

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

Syntax

L2Bin( <nNumber> ) --> cInteger

Arguments

<nNumber>
A numeric value in the range of -(2ˆ31) to +(2ˆ31) - 1.

Return

The function returns a four-byte character string representing a 32-bit signed long binary integer .

Description

L2Bin() is a binary conversion function that converts a numeric value (Valtype()=="N") to a four-byte binary number (Valtype()=="C").

The range for the numeric return value is determined by a signed long integer. If <nNumber> is outside this range, a runtime error is raised.

L2bin() is the inverse function of Bin2L().

Info

See also:Asc(), Bin2I(), Bin2L(), Bin2U(), Bin2W(), Chr(), I2Bin(), U2Bin(), W2Bin()
Category: Binary functions , Conversion functions
Source:rtl\binnum.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates return values of L2Bin().

   PROCEDURE Main
      LOCAL c

      c := L2Bin(0)
      ? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
      //      0          0          0          0

      c := L2Bin(1)
      ? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
      //      1          0          0          0

      c := L2Bin(-1)
      ? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
      //    255        255        255        255

      c := L2Bin(256)
      ? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
      //      0          1          0          0

      c := L2Bin(-256)
      ? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
      //      0        255        255        255

      c := L2Bin(2147483647)
      ? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
      //    255        255        255        127

      c := L2Bin(-2147483648)
      ? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
      //      0          0          0        128
   RETURN

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