JAVA舍入,截尾测试

/**
 * 
 * @author caryt
 *
 */
public class test {
  
/**
* @param args
*/

public static void main(String[] args) {
// TODO Auto-generated method stub

//结尾:
System.out.println("舍入截尾测试:"+(int)0.6f+" : "+(int)0.7);
//舍入须要round()方法

System.out.println("舍入:"+Math.round(0.6f)+" 舍入:"+Math.round(0.7)+" 截尾:"+Math.round(0.4f)+" 截尾:"+Math.round(0.4));测试

}spa

}.net

out:  舍入截尾测试:0 : 0
舍入:1 舍入:1 截尾:0截尾:0get

相关文章
相关标签/搜索