I am working with data that is b and in more detail is described by a. Atleast that is how i understand it. Any further links to basic bitwise operations are appreciated. All objects i am looking at have b as 0x8000. I need to find out a from c.
I have:
ushort a
ushort b
a is from 2-5
b = 0x8000
ushort c = (ushort)( a | b )
can i and if yes how can i come from c to a?
I tried ( a & b ) but that leads me to b not a. I am realy stuck although i know it should be easy if possible if i would understand the operations.
Basically, it's c AND NOT b
.
ushort a2 = (ushort) (c & ~b);
but only because a is from 2-5 and that is smaller than 0x8000.
When a
and b
start to overlap in bits you're stranded.
This will only work if a if smaller that b, which is true from the interval you give for a.
Both of these will work :
a = (ushort) (c & ~b)
a = (ushort) c - b
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.