My skills in this area are new and therefore unproven so if I'm wrong then I learn something new, which is at least a part of the point of Stack Overflow.
Would a bitmask and XOR work also?
Like so?
var orginal=
var mask =00001110 //I may have the mask wrong
var value=1011 1110
var result=value^mask;
I might be misunderstanding things, forgive me if I've screwed up entriely.