开发者

Rounding vs truncation in Math class in Java

开发者 https://www.devze.com 2023-03-26 06:24 出处:网络
At present I am doing this: long x = Math.round((numberFormat(Collections.min(te开发者_如何学运维mpList)) * 1000) / 1000);

At present I am doing this:

long x = Math.round((numberFormat(Collections.min(te开发者_如何学运维mpList)) * 1000) / 1000);

In the above statement tempList is List type. Suppose Collections.min(tempList) returns the value 236.589; x is assigned the value 237, but I want 236 only.

How do I do that?


Use the floor-method instead of round.

0

精彩评论

暂无评论...
验证码 换一张
取 消