是否有符合IEEE754(r)的Java实现?
是否有任何完全兼容的IEEE754r实现可用于Java,它们支持Java选择省略的所有功能(或者更确切地说,高级语言通常喜欢省略):是否有符合IEEE754(r)的Java实现?,java,floating-point,ieee-754,Java,Floating Point,Ieee 754,是否有任何完全兼容的IEEE754r实现可用于Java,它们支持Java选择省略的所有功能(或者更确切地说,高级语言通常喜欢省略): 陷阱 粘旗 定向舍入模式 延长/长双 四精度 DPD(密集小数) 在任何人弄错之前澄清一下:我不希望JVM提供对上述内容的任何支持,只希望一些类能够实现软件中的类型和操作,基本上是现有primitve包装类Float/Double的风格。实现了以下功能: double nextAfter(double x, double y) - returns the do
- 陷阱
- 粘旗
- 定向舍入模式
- 延长/长双
- 四精度
- DPD(密集小数)
double nextAfter(double x, double y) - returns the double adjacent to x in the direction of y
double scalb(double x, int e) - computes x*2e quickly
boolean unordered(double c1, double c2) - returns true iff the two cannot be compared numerically (one or both is NaN)
int fpclassify(double value) - classifies a floating-point value into one of five types:
FP_NAN: "not any number", typically the result of illegal operations like 0/0
FP_INFINITY: represents one end of the real line, available by 1/0 or POSITIVE_INFINITY
FP_ZERO: positive or negative zero; they are different, but not so much that it comes up much
FP_SUBNORMAL: a class of numbers very near zero; further explanation would require a detailed examination of the floating-point binary representation
FP_NORMAL: most values you encounter are "normal"
double copySign(double value, double sign) - returns value, possibly with its sign flipped, to match "sign"
double logb754(double value) - extracts the exponent of the value, to compute log2
double logb854(double value) - like logb754(value), but with an IEEE854-compliant variant for subnormal numbers
double logbn(double value) - also computing log2(value), but with a normalizing correction for the subnormals; this is the best log routine
double raise(double x) - not actually an IEEE754 routine, this is an optimized version of nextAfter(x,POSITIVE_INFINITY)
double lower(double x) - not actually an IEEE754 routine, this is an optimized version of nextAfter(x,NEGATIVE_INFINITY)
所有这些例程都有浮点变量,只是参数和返回类型不同。类是org.dosereality.util.IEEE754
不,不存在完全兼容的IEEE754R实现。不仅使用Java,而且使用所有当前可用的语言(状态2012年7月) 编辑:海报要求IEEE754 R支持,与IEEE754-2008相同。如果我想补充为什么没有这样的事情的所有原因,这将是漫长的
- 陷阱:不,使用SIGFPE调用自己的溢出、下溢、不精确等例程是不正确的 陷阱。参见IEEE754(旧版本)第页。21什么构成陷阱。 给南斯发信号。NaN有效负载访问。标记访问。 列举能做到这一点的语言
- 舍入模式:新标准将RounditesToWay(第16页)定义为新的舍入模式。 不幸的是,AFAIK没有支持这种模式和模式的处理器 也没有软件仿真
- 四精度:仅在极少数编译器中受支持,甚至更少的未损坏的编译器中受支持
- 密集小数:可能仅在使用小数的语言中支持, e、 g.COBOL
所有集合的交集:空集合。没有一个什么都没有。如果有一篇引文来解释为什么现有的实现没有完全兼容,那就太好了。我有点期待没有软件实现,但另一方面,我有点惊讶,似乎根本没有开源实现。我不理解你对陷阱的评论,据我所知,当设置5个标志中的任何一个并且未禁用特定的陷阱时,操作(add、div等)应该调用用户指定的处理程序(这是我在旧MC68881中使用的)。陷阱需要提供足够的信息,以便用户处理程序完成或重新运行操作(我有一些想法,如何在Java这样的高级语言中实现这一点,但可能会有一些限制,例如无法更改源操作数)。除非我完全错过了源代码中的要点,这只是我要求的一小部分。@Durandal可能一点也没有错过。这是一个我能够找到的,提供了一些信息。