Any implementations compatible with IEEE754 (r) for Java?

Are there fully compatible IEEE754r implementations for Java that offer support for all the features that Java chose to omit (or rather, high-level languages, as a rule, omit):

  • Trap
  • Sticky flags
  • Directional Rounding Modes
  • Extended / long double
  • Square precision
  • DPD (tightly packed decimal places)

Clarification before someone makes a mistake: I'm not looking for the JVM to offer any support for the above, only some classes that implement types and operations in software, basically something in the style of an existing primitive wrapper classes Float / Double .

+8
java floating-point ieee-754
source share
2 answers

No, there is no fully compatible implementation of IEEE754R. Not only in Java, but in all currently available languages ​​(Status July 2012).

EDIT: The poster requested support for the IEEE754 R, which is identical to IEEE 754-2008. If I want to add all the reasons why such a thing does not exist, it will be a long time.

  • Traps: no, calling your own procedures using OVERFLOW, UNDERFLOW, INEXACT, etc. SIGFPE is not a trap. See IEEE754 (old) p. 21 for what constitutes a trap. Alarm NaNs. Access to the NaN payload. Access to the flag. List the languages ​​that can do this.

  • Rounding Modes: The new standard defines roundTiesToAway (p. 16) as the new rounding mode. Unfortunately, AFAIK has no processors that support this mode and there is no software emulation.

  • Square precision: only supported by very few compilers and even fewer compilers that are not broken.

  • Tightly packed decimal places: probably only supported in languages ​​that use decimal places, like COBOL.

Intersection of all sets: empty set. None. Nothing.

+5
source share

It is with the following source that the following functions are implemented:

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) 

"All of these routines also have floating point options that differ only in arguments and return types. Class is org.dosereality.util.IEEE754"

Link to Internet Error 2003

0
source share

All Articles