Clear bit another approach

To clear a particular bit, can’t we just perfrom bitwise XOR with mask?

mask in this case will be (1 << i)

what if the ith bit is already zero? then instead of clearing it, it will set the bit