programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Is there a easy way to find the solution?

Juan Zhang
Greenhorn
Posts: 13
Hi,
Is there a easy way to find the solution by hand calculation?
1) int a = 0x67
int b = 0xBD
a^b = ?
2)(byte)0x81 >> 2 = ?
Thanks

Carl Trusiak
Sheriff
Posts: 3341
This post belongs in Java General(Beginner) I'm moving it there.

Carl Trusiak
Sheriff
Posts: 3341
Sure, one of the reasons that hexadecimal is useful in programming is one hexdigit can represent 4 bits and 1 byte can easily be represented by 2 hexdigits.
0x0 = 0000
0x1 = 0001
0x2 = 0010
0x3 = 0011
0x4 = 0100
0x5 = 0101
0x6 = 0110
0x7 = 0111
0x8 = 1000
0x9 = 1001
0xA = 1010
0xB = 1011
0xC = 1100
0xD = 1101
0xE = 1110
0xF = 1111
So, 0x67 = 0110 0111, 0xBD = 1011 1101 and 0x81 = 1000 0001
Read the Story Cat and Mouse Game with Bits to see how the operations work
------------------
Hope This Helps
Carl Trusiak, SCJP2

 Don't get me started about those stupid light bulbs.