最近看到一道面试题:网上也没有什么好的答案;我自己总结了一下:
题目:如何取小数点前两位并四舍五入
public void RoundMath{
public static void main(){
float t=1898.879f;
t=Math.round(t);
t/=100;
t=Math.round(t);
System.out.println(t);
}
}
题目:如何取小数点前两位并四舍五入
public void RoundMath{
public static void main(){
float t=1898.879f;
t=Math.round(t);
t/=100;
t=Math.round(t);
System.out.println(t);
}
}