| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Translates bits of an integer to a character string.
BitToC( <nInteger> , ;
<cBitPattern>, ;
[<lSpaces>] ) --> cResult
The function returns a character string containing the characters of <cBitPattern> which are located at the same position as a bit set in <nInteger>. When <lSpaces> is .T. (true), the return string includes blank spaces at the position of unset bits. When it is .F. (false), unset bits of <nInteger> are not included in the return string.
| See also: | CtoBit(), CtoN(), HB_BitIsSet() |
| Category: | CT:NumBits , Bitwise functions , Numbers and Bits |
| Source: | ct\numconv.prg |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example displays results of BitToC() in comparison to
// the binary representation of a number
PROCEDURE Main
// binary representation of 11
? NtoC( 11, 2, "0" ) // result: 1011
// zero bit is ingnored
? BitToC( 11, "ABCD" ) // result: ACD
// zero bit yields blank space
? BitToC( 11, "ABCD", .T. ) // result: A CD
RETURN
http://www.xHarbour.com