Skip to question
SystemVerilogDesignVerificationFirmwareArchitectureASIC Interview Questions→
/Interview questions/Clear the lowest set bit

Q120·Free·SystemVerilog

Clear the lowest set bit

Difficulty
Easy
Topic
Bit Manipulation
Language
SV
Interview prompt

Question

Return x with its least-significant 1 bit cleared.

Candidate starting point

Implementation scaffold

function automatic int unsigned clear_lowest_one(int unsigned x);
  // TODO: implement.
endfunction
Reviewed example

Trace 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.
Exact question handoffPractice Q120

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessEach time you open this Solution, one Practice Credit is used; it is not permanently unlocked. Premium Solution content also uses one credit per opening.
Continue learning

Firmware Guide

Review algorithms, data structures, fixed-memory reasoning, concurrency, and silicon bring-up.

  • Bit Manipulation
  • Bits
  • Mask
Firmware Guide →
Continue practicing

Related questions

Q501 · Bit ManipulationGet, set, clear, and toggle one bitEasyP→Q692 · Bit ManipulationIsolate the lowest set bitEasyP→Q815 · Bit ManipulationInsert a packed bit fieldMediumP→Q574 · Bit ManipulationReverse a bit vectorEasyP→Q823 · Bit ManipulationCheck for a power of twoEasyP→
ASIC.FYI · Learn silicon end to end.info@asic.fyi