gpt4 book ai didi

java - 总是向下舍入一个数字

转载 作者:行者123 更新时间:2023-11-29 09:49:22 25 4
gpt4 key购买 nike

我想知道如何指示 Java 始终向下舍入给定的数字。

例如:

1.08 rounds to 1
1.88 rounds to 1
1.999999999999 rounds to 1
0.0002 rounds to 0
123.77 rounds to 123

有什么建议吗?

提前致谢! :)

最佳答案

这就是Math#floor does :

Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer

关于java - 总是向下舍入一个数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12625408/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com