I have a CFBitVector that looks like '100000000000000' I pass an array of bytes to CFBitVectorGetBits , which then contains the values ββfrom this CFBitVector . After this call, bytes[2] looks like this:
bytes[0] == '0x80' bytes[1] == '0x00'
This is exactly what I would expect. However, when copying the contents of bytes[2] to unsigned int bytesValue, value is 128 , when it should be 32768 . The decimal value 128 is represented by the hexadecimal value 0x0080 . Essentially, it seems that the byte order is reversed when memcpy executed. What's going on here? Is this just a content issue?
thanks
CFMutableBitVectorRef bitVector = CFBitVectorCreateMutable(kCFAllocatorDefault, 16); CFBitVectorSetCount(bitVector, 16); CFBitVectorSetBitAtIndex(bitVector, 0, 1); CFRange range = CFRangeMake(0, 16); Byte bytes[2] = {0,0}; unsigned int bytesValue = 0; CFBitVectorGetBits(bitVector, range, bytes); memcpy(&bytesValue, bytes, sizeof(bytes)); return bytesValue;
source share