xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

U2bin()

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

Syntax

U2bin( <nNumber> ) --> cInteger

Arguments

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

Return

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

Description

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().

Info

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

Example

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

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