---
title: "JAVA舍入，截尾测试"
author: "caryt"
date: "2013-06-27T11:35:00Z"
tags: []
slug: "java"
draft: false
lastmod: "2014-04-25T10:57:15Z"
id: 2054452
url: "https://caryt.iteye.com/blog/2054452"
---

/\**  
\*  
\* @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));

}

}

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