Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Left Shift operation

 
Munish Gulati
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Function:
test(int 1,String s){
if((i>>30)!=(i>>>1)) SOP(exp);
}
Values Passed :
test(1<<30,"1<<30")
How the values will be calculated :
 
Raja Sagar Panamgipalli
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Karan,
when r u taking the SCJP exam i have scheduled for 25th Sep
plz reply.
 
venu gopal
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Karan,
I think this will clear your doubt
class Test {
public static void main(String args[]) {
test(1<<30,"1<<30"); // Here 1 << 30 will be passed to the function
// 1 << 30 is 1 * 2 Power 30 i.e 0100 0000 0000 0000 0000 0000 0000 0000 i.e 1073741824


}
static void test(int i,String s){
if((i>>30)!=(i>>>1)){
// if((1073741824 >> 30) != ( 1073741824 >>>1)) {
// if( 1 != 1073741824)
System.out.println("(i>>30)--> "+ (i>>30));
System.out.println("(i>>>1)--> "+(i>>>1));
System.out.println("Not Equal");
}
}
}
[ August 13, 2003: Message edited by: venu gopal ]
 
Munish Gulati
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks venu. Now I got that.
hi javagreenhorn..i am planning to take it on 25 Aug.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic