How to customize the form of rounding

放肆的年华 提交于 2019-12-04 12:22:29

Simply do this:

double threshold = 0.7;
Math.round(x - threshold + 0.5);

You could write a method that takes a double variable as input and returns the integer based on the first digit after the point. For instance, you could convert the input to a String and delimit it at the decimal point. Then check if the first digit after the point is less or greater than 6.

Math.floor(x + 0.6);

It possibly may solve your question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!