2's Power

相关内容:

1.Math类

2.BigDecimal类

函数实现:

private static int is2sPow(double in){
double lo=Math.log(in)/Math.log((double)2);
BigDecimal dataRe=new BigDecimal(lo);
BigDecimal dataRo=new BigDecimal(Math.round(lo));
return dataRe.compareTo(dataRo);
}
结果说明:
-1:不足上界
0:2's power
+1:超越下界

posted @ 2017-02-21 11:04  空山皓月  阅读(135)  评论(0编辑  收藏  举报