xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

W2bin()

Converts a numeric value to an unsigned short binary integer (2 bytes).

Syntax

W2Bin( <nNumber> ) --> cInteger

Arguments

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

Return

The function returns a two-byte character string representing a 16-bit unsigned short binary integer .

Description

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

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

Info

See also:Asc(), Bin2i(), Bin2l(), Bin2u(), Bin2w(), Chr(), I2bin(), L2bin(), U2bin()
Category: Binary functions , Conversion functions
Source:rtl\binnumx.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

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

   PROCEDURE Main
      LOCAL cInt

      cInt := W2bin(0)
      ? Asc( cInt[1] ), Asc( cInt[2] )  // result:   0    0

      cInt := W2bin(1)
      ? Asc( cInt[1] ), Asc( cInt[2] )  // result:   1    0

      cInt := W2bin(256)
      ? Asc( cInt[1] ), Asc( cInt[2] )  // result:   0    1

      cInt := W2bin(32768)
      ? Asc( cInt[1] ), Asc( cInt[2] )  // result:   0  128

      cInt := W2bin(65535)
      ? Asc( cInt[1] ), Asc( cInt[2] )  // result: 255  255

   RETURN

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