| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Converts a numeric value to an unsigned long binary integer (4 bytes).
U2bin( <nNumber> ) --> cInteger
The function returns a four-byte character string representing a 32-bit unsigned long binary integer.
U2bin() 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 an unsigned long integer. If <nNumber> is outside this range, a runtime error is raised.
U2bin() is the inverse function of Bin2U().
| See also: | Asc(), Bin2i(), Bin2l(), Bin2u(), Bin2w(), Chr(), I2bin(), L2bin(), W2bin(), Word() |
| Category: | Binary functions , Conversion functions |
| Source: | rtl\binnumx.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example demonstrates return values of U2bin().
PROCEDURE Main
LOCAL c
c := U2bin(0)
? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
// 0 0 0 0
c := U2bin(1)
? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
// 1 0 0 0
c := U2bin(256)
? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
// 0 1 0 0
c := U2bin(65536)
? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
// 0 1 0 0
c := U2bin(2147483648)
? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
// 0 0 0 128
c := U2bin(4294967295)
? Asc(c[1]), Asc(c[2]), Asc(c[3]), Asc(c[4])
// 255 255 255 255
RETURN
http://www.xHarbour.com