简体   繁体   English

Math.ceil()方法不适用于双精度值

[英]Math.ceil() method is not working with double values

I want to roundoff the values of double variable to the next positive whole number irrespective of the what i get after the decimal point. 我想将double变量的值四舍五入到下一个正整数,而不管我在小数点后得到什么。 So i searched about it and found Math.ceil() method do this work but when i am using it in my code it is not giving the next positive whole number. 所以我搜索了一下,发现Math.ceil()方法可以完成这项工作,但是当我在代码中使用它时,它没有给出下一个正整数。

Please help me as i already know we need to provide double values and i am providing all the double values only but still its working like roundoff function. 请帮助我,因为我已经知道我们需要提供双精度值,而我仅提供所有双精度值,但仍像四舍五入函数一样工作。

Below is My Code :- 以下是我的代码:-

completedorders = Double.parseDouble(totalcompletedorders);

Log.i("COMPLETED ORDERS" , String.valueOf(completedorders));

double l = Math.ceil(completedorders / 5.0);

Log.i("Value of L", String.valueOf(l));

When i am logging the values in the Logcat i am getting these values. 当我在Logcat中记录值时,我正在获取这些值。

05-28 16:16:48.125 26657-26657/com.example.example I/COMPLETED ORDERS: 7.0
05-28 16:16:48.125 26657-26657/com.example.example I/Value of L: 1

代码绝对正确,但问题是android studio出现了问题,它在后台执行了我以前的代码,该代码具有math.round方法。...现在我已经清理了项目并卸载并重新安装了应用程序...现在工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM