Hi! This is probably a real dumb question, but what's the advantage to using OR and XOR for a bit addition/subtraction if I know what the additional value should be and I know that it hasn't already been applied to the original value?
In other words, if I want the second binary digit in 61 to be set, I can just add 2 (61 + 2) instead of using OR (61 OR 2), they both give the same answer, 63.
I understand that it would be safer to use OR in the event that you haven't evaluated whether or not that bit field is set yet (63 OR 2), but is that the only advantage it would give?
I'm just curious from a learning perspective. Thanks!
In other words, if I want the second binary digit in 61 to be set, I can just add 2 (61 + 2) instead of using OR (61 OR 2), they both give the same answer, 63.
I understand that it would be safer to use OR in the event that you haven't evaluated whether or not that bit field is set yet (63 OR 2), but is that the only advantage it would give?
I'm just curious from a learning perspective. Thanks!