Exercise 2: Verifying the Idempotent Law on a Feature-Flag Value — Possible Solution ==================================================================== GIVEN ------------------------------ DARK_MODE = 0b1000, BETA = 0b0100, ADMIN = 0b0010, DEBUG = 0b0001 enabled = DARK_MODE | BETA STEP 1: COMPUTE enabled ------------------------------ DARK_MODE | BETA = 0b1000 | 0b0100 = 0b1100 (decimal 12) STEP 2: COMPUTE enabled | enabled ------------------------------ 0b1100 | 0b1100 = 0b1100 (decimal 12) STEP 3: COMPARE ------------------------------ enabled | enabled = 0b1100 enabled = 0b1100 They are identical - the idempotent law holds: enabled | enabled == enabled. WHY THIS LAW ALWAYS HOLDS, FOR ANY COMBINATION OF FLAGS ------------------------------ OR-ing a bit pattern with itself compares each bit position against itself - and any single bit OR-ed with its own value always produces that same bit back (0|0=0, 1|1=1) - so every bit position in the result is guaranteed to match the original, regardless of which specific flags happen to be set. WHY THIS WORKS AS AN ANSWER ------------------------------ The actual bit values are computed explicitly at each step rather than just asserted to match, and the one-sentence generalization is grounded in what OR actually does at the level of a single bit position (comparing a value against itself), not just restated as "the idempotent law says so."