哪位大哥给我分析一下下面这段Java代码,越详细越好!

Java代码:
import java.math.*;
import java.util.Scanner;
public class Main
{
public static void main( String[] args )
{
Scanner sc = new Scanner( System.in );
int cases;
cases = sc.nextInt();
while ( ( cases-- ) != 0 )
{
BigInteger m = new BigInteger( sc.next() );
BigInteger n = new BigInteger( sc.next() );
n = n.divide( m );
int l = n.bitLength() - 1;
if ( l % 6 == 0 )
System.out.println( 0 );
else
System.out.println( ( 1 << ( l%6 ) ) );
}
}
}

Scanner sc = new Scanner(System.in);//输入的数字
int cases;//声明一个变量cases
cases = sc.nextInt();//把输入的数字赋值到变量cases
while ((cases--) != 0) {//判断cases的值是否等于0,如果不是就进入while循环
BigInteger m = new BigInteger(sc.next());//输入一个数转成BigIteger类型
BigInteger n = new BigInteger(sc.next());//输入一个数转成BigIteger类型
n = n.divide(m);//两个数相除,n除以m

/*返回此 BigInteger 的最小的二进制补码表示形式的位数,不包括 符号位。
* 对于正 BigInteger,这等于常规二进制表示形式中的位数。
* (计算 (ceil(log2(this < 0 ? -this : this+1)))。)*/
int l = n.bitLength() - 1;
if (l % 6 == 0)
System.out.println(0);
else
System.out.println((1 << (l % 6)));//(1%6)得到的二进制的值向左移一位
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-08-01
楼上已经很详细了!
第2个回答  2011-08-01
太详细了!!
第3个回答  2011-08-01
已经很详细了,跟教科书似地
第4个回答  2011-08-01
可以看动了吧,那么清楚
相似回答