15,957,892 members
See more:
...

1. how do I get the inverse? is there way in bitwise operator?

Thanks agian.

What I have tried:

`return b |= inverse(a); // is this correc?`
Posted
Updated 7-Nov-22 6:47am
11917640 Member 7-Nov-22 6:44am
return (b & (~a));

## Solution 1

The tilde symbol is one way : `~`. It is the binary negation operator. The boolean negation operator is the exclamation mark : `!`. The docs : cplusplus.com : operators[^].

What you tried, the `|=`, is the or equals operation.

ETA: You can display an integer in hexadecimal format like this :
C
`printf( "integer value is %08X\n", integerValue );`
That format specifier, the `%08X` part, would display eight hex digits with leading zeros.

v2
CPallini 7-Nov-22 12:35pm
5.
Rick York 7-Nov-22 12:47pm
Thank you sir.

## Solution 3

Quote:
1. how do I get the inverse? is there way in bitwise operator?
Yes, there is, as Rick already suggested, it is the bitwise NOT (`~`, see Arithmetic operators - cppreference.com[^]).
Quote:
Usually is it an `AND` mask.

To summarize (as 11917640 Member suggested)
C++
`(b & (~a))`
should do the trick.

## Solution 2

```unsigned char operator(unsigned char a, unsigned char b)
{

return (b |= reverse(a);
}```