const unsigned char double_nybble[] = { 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F, 0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF}; int DoubleBits(int bits) { return (double_nybble[(bits & 0xf0) >> 4] << 8) + double_nybble[bits & 0x0f]; }