四舍五入 Math.round(234.6) //235
不要四舍五入 (int)(234.8)   //234

解决方案 »

  1.   

    Math.round(3454.8345363)
    (int)(3454.8345363+0.5)
      

  2.   

    public class sf{
    public static void main(String[] argc){
    String x="3454.8345363";
    sf y=new sf();
    y.to_int(x);

    } public void to_int(String data){
    int changetoint1=0;
    int changetoint2=0;
    changetoint1=(new Double(data)).intValue();;
    changetoint2=(new Double(Double.parseDouble(data)+0.5)).intValue();
    System.out.println("四舍5入"+changetoint1);
    System.out.println("不四舍5入"+changetoint2);
    return;
    }
    }
      

  3.   

    to yorkchen(天同)
    sorry!我看到你的答案的时候我已经给分了,谢谢你的参与,下次一定多给你点分!
    谢谢大家的帮忙!