xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

ClearBit()

Sets one or more bits of a numeric integer value to 0.

Syntax

ClearBit( <nInteger>|<cHex>,[<nBitPos,...>]) --> nNewValue

Arguments

<nInteger>
A numeric 32-bit integer value can be specified as first parameter.
<cHex>
Alternatively, the integer can be passed as a hex-encoded character string (see NumToHex()).
<nBitPos>
The positions of the bits to clear are defined as a comma separated list of numeric integer values. The range for <nBitPos> is 1 to 32.

Return

The function returns a numeric integer value with the bits at the specified positions set to 0.

Info

See also:IsBit(), NumAND(), NumNOT(), NumOR(), NumXOR(), SetBit()
Category: CT:NumBits , Numbers and Bits
Source:ct\bit2.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays results of ClearBit() along with the
// binary representation of numbers.

   PROCEDURE Main

      ? NtoC( 255, 2, 8, "0" )         // result: 11111111

      ? n := ClearBit( 255, 1, 7 )     // result:   190.00
      ? NtoC( n, 2, 8, "0" )           // result: 10111110

      ? n := ClearBit( 255, 2, 4, 6 )  // result:   213.00
      ? NtoC( n, 2, 8, "0" )           // result: 11010101

   RETURN

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