在Java中,进行某些数据处理时,向上舍入和向下舍入通常需要对结果进行向上舍入或向下舍入操作。 Java有以下特殊方法:
向上取math.ceil(doublea )
向下取math.floor(doublea )
例如:
双精度a=30; 双精度b=20; 双精度c=a/b; system.out.println('c=='c ); //1.5 system.out.println (c==' math.ceil ) ); //2.0系统. out.println (math.floor (c ) ); //1.0这两种方法的详细情况如下。
math.ceil (双精度) )。
是math.floor(doublea )
转载于:https://www.cn blogs.com/Bruce Shao/p/8675271.html