Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Clear the lowest set bit

Hardware interview practice

Clear the lowest set bit

EasyBit ManipulationSystemVerilog

Return x with its least-significant 1 bit cleared.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Reviewed example

Work through one case

Input
value = 8'b1011_0000
Expected output
8'b1010_0000

ANDing with value - 1 clears only the lowest set bit, which is bit 4 here.

What to cover

Requirements

  1. Return zero when x is zero.
  2. Use one arithmetic and one bitwise operation.
Continue practicing

Related questions

Bit ManipulationCheck for a power of two→Bit ManipulationGet, set, clear, and toggle one bit→
asic.fyi · Learn silicon end to end.info@asic.fyi