Bit Manipulation Questions
Working directly with binary representations: bitwise operators, masking, shifting, bit counting, and integer-encoding tricks. Covers using bit-level operations for compact state, fast arithmetic, and low-level optimization. Especially relevant where memory and cycles are constrained.
A 12-byte telemetry packet must pack many variable-length fields bitwise to minimize airtime. As an embedded developer, propose a portable bit-field layout and parsing/writing strategy that addresses alignment, endianness, future extension (versioning), and error detection. Provide pseudocode or an outline of your parser and how you would test it across big/little-endian hosts.
Design a Bloom filter to fit in 8 KB of SRAM for up to 500 32-bit device IDs with a target false-positive rate under 1%. Choose bit-array size m and number of hash functions k, explain how to implement add() and contains() using bitwise operations efficiently, and discuss using double-hashing to reduce hash computations on an MCU.
Your SPI peripheral occasionally receives bytes that are bit-shifted by 1–2 positions (intermittent). As an embedded developer, outline a systematic debugging checklist (hardware and software) to isolate and fix the cause. Include checks for CPOL/CPHA, bit order, FIFO/DMA alignment, clock jitter, grounding, and test patterns to reproduce the issue.
Implement uint8_t crc8_update(uint8_t crc, uint8_t data) in C for the CRC-8 polynomial 0x07 (x^8 + x^2 + x + 1) using the bit-at-a-time algorithm (no lookup table). Then explain how to convert this to a table-driven implementation and discuss memory vs CPU trade-offs on small microcontrollers.
Describe the semantics and typical use-cases of the following bitwise operators in C/C++: &, |, ^, ~, <<, >>. For each operator give a short C example (use 32-bit unsigned integers) and explain how behavior differs when applied to signed vs unsigned types. Also explain the difference between logical operators (&&, ||) and bitwise operators, and mention common embedded pitfalls (shifting by >= width, operator precedence, mixing signedness).
Unlock Full Question Bank
Get access to all 33 Bit Manipulation interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.