gpt4 book ai didi

java - RoundingMode HALF_EVEN 类似于用于 float 的舍入策略

转载 作者:行者123 更新时间:2023-11-29 04:49:36 26 4
gpt4 key购买 nike

RoundingMode.HALF_EVEN 的 javadoc 指出:

This rounding mode is analogous to the rounding policy used for float and double arithmetic in Java.

这句话到底是什么意思?我只注意到只使用了 HALF_UP,例如 String.format 或 Decimal 格式。

最佳答案

“浮点运算的 IEEE 标准”(Java 数字在其后建模)要求中间结果使用必要的最大精度并在最后四舍五入到结果宽度。舍入的默认规则是 HALF_EVEN。

参见 https://en.wikipedia.org/wiki/IEEE_floating_point#Rounding_rules

关于java - RoundingMode HALF_EVEN 类似于用于 float 的舍入策略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35898779/

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