Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bitwise Operators

 
Anupama Kota
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
char v1 = ')';//41
byte v2 = 13;

~v1 = -42;
v1&v2 = 9;
v1|v2 =45;

I know the process that the value is coveted to binary and then operate both regarding to the operator.
But in the exam it is time taken process.That we have to rember all Ascii values.May be some times it goes worng in recollecting.
Is there any other simple way like 12>>2 is 12 / (2(power)2)??
 
Haining Mu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
really? are we require to remember ASCII?
 
Junilu Lacar
Bartender
Pie
Posts: 7320
45
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you are not expected to remember the ASCII code table.
It helps to know how to convert numbers from one base to another though. For bitwise operation questions, it's best to know the binary representations of 0x00 to 0x0F, how to get the one's complement and two's complement, how to convert from decimal to binary and vice versa.
Junilu
 
Anupama Kota
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Junilu
Yes,I understand how to convert both binary to hex,oct and vice versa,1's and 2's complement.But if this type of question come in Exam then what we have to do.
We have to know na about ")" that character is represented as decimal 41 .How we know this??
If mine thinking is wrong pl correct me.
 
Junilu Lacar
Bartender
Pie
Posts: 7320
45
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's highly unlikely that Sun will give any questions that require you to memorize the ASCII code table. The questions I got that involved bitwise operators were pretty straightforward. Don't worry about it.
Junilu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic