• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Left Shift operation

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 :
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Karan,
when r u taking the SCJP exam i have scheduled for 25th Sep
plz reply.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks venu. Now I got that.
hi javagreenhorn..i am planning to take it on 25 Aug.
 
Bras cause cancer. And tiny ads:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic