| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Converts a numeric value to a signed long binary integer (4 bytes).
L2Bin( <nNumber> ) --> cInteger
The function returns a four-byte character string representing a 32-bit signed long binary integer .
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().
| 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 |
// 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
http://www.xHarbour.com