wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Left Shift operation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Left Shift operation" Watch "Left Shift operation" New topic
Author

Left Shift operation

Munish Gulati
Ranch Hand

Joined: Aug 06, 2003
Posts: 37
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 :


Munish Gulati<br />SCJP 1.4<br />Albert Einstein: There are only two ways to live your life. One is as though nothing is a miracle. The other is as though everything is a miracle.
Raja Sagar Panamgipalli
Ranch Hand

Joined: Aug 13, 2003
Posts: 109
Hey Karan,
when r u taking the SCJP exam i have scheduled for 25th Sep
plz reply.


SCJP 1.4<br />SCBCD 1.3
venu gopal
Ranch Hand

Joined: Nov 21, 2000
Posts: 40
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

Joined: Aug 06, 2003
Posts: 37
Thanks venu. Now I got that.
hi javagreenhorn..i am planning to take it on 25 Aug.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Left Shift operation