| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Sets one or more bits of a numeric integer value to 1.
SetBit( <nInteger>|<cHex>, [<nBitPos,...>]) --> nInteger
The function returns a numeric integer value with the bits at the specified positions set to 1.
| See also: | IsBit(), NumAND(), NumNOT(), NumOR(), NumXOR() |
| Category: | CT:NumBits , Bitwise functions , Numbers and Bits |
| Source: | ct\bit2.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example displays results of SetBit() along with the
// binary representation of the numbers.
PROCEDURE Main
? NtoC( 0, 2, 8, "0" ) // result: 00000000
? n := SetBit( 0, 1, 7 ) // result: 65.00
? NtoC( n, 2, 8, "0" ) // result: 01000001
? n := SetBit( 0, 2, 4, 6 ) // result: 42.00
? NtoC( n, 2, 8, "0" ) // result: 00101010
RETURN
http://www.xHarbour.com