I'll throw another way into the mix which I think is clearer and doesn't require conversion to bit numbers for the ClearBit()
? bitand( nFlags, bitnot( 8 ) )
The bitnot() inverts all of the bits, so it puts a 0 for each bit of what you are wanting to turn off and 1s everywhere else. When this is bitanded to the other value it changes them to 0.
This will also work if you are wanting to clear more than one bit at a time.