De-normalized numbers in Java are guaranteed?

huangapple go评论51阅读模式
英文:

Java are de-normalized numbers guarantied?

问题

Java标准对浮点数的确切行为有何规定吗?

是否有保证它会使用非规格化数?有常量Float.MIN_VALUEFloat.MIN_NORMAL,但当硬件不处理非规格化数时会发生什么情况?

在更具体的情况下,我是否有保证在x86/64系统上,每个Java实现都不会禁用非规格化值?

我可以禁用这种行为并将所有非规格化数视为零吗?

英文:

Does the Java Standard impose anything about the exact behavior of floating points?

Is there any guaranty that it will use de-normalized numbers? There are the constants Float.MIN_VALUE and Float.MIN_NORMAL, but what happens when the hardware does not handle de-normalized numbers?

In a more concrete case, am I guarantied that on a x86/64 system that every java implementation does not disable de-normalized values?

Can I disable this behavior and consider all de-normalized numbers as zero?

答案1

得分: 3

Java语言规范第4.2.4节 要求 支持非规格化数字:

> 具体而言,Java编程语言要求支持IEEE 754 非规格化 浮点数和渐进下溢,这使得更容易证明特定数值算法的理想特性。如果计算结果是非规格化数字,浮点操作不会“刷成零”。

如果硬件不处理非规格化数字,必须在JVM中进行软件补丁以使其符合规范。

英文:

The Java Language Specification section 4.2.4 requires support for denormalized numbers:

> In particular, the Java programming language requires support of IEEE 754 denormalized floating-point numbers and gradual underflow, which make it easier to prove desirable properties of particular numerical algorithms. Floating-point operations do not "flush to zero" if the calculated result is a denormalized number.

If the hardware does not handle de-normalized numbers, this has to patched in software in the JVM for it to be compliant with the specification.

huangapple
  • 本文由 发表于 2020年8月1日 19:17:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63204585.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定