Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any IEEE754(r) compliant implementations for Java?

Are there any fully compliant IEEE754r implementations available for Java that offer support for all the features Java chose to omit (or rather high level languages in general like to omit):

  • Traps
  • Sticky flags
  • Directed rounding modes
  • Extended/long double
  • Quad precision
  • DPD (densly packed decimals)

Clarification before anyone gets it wrong: I'm not looking for the JVM to offer any support for the above, just some classes that do implement the types and operations in software, basically something in the style of the already existing primitve wrapper classes Float/Double.

like image 407
Durandal Avatar asked Jul 13 '12 16:07

Durandal


People also ask

Does Java use IEEE 754?

Java uses a subset of the IEEE 754 binary floating point standard to represent floating point numbers and define the results of arithmetic operations. Virtually all modern computers conform to this standard. A float is represented using 32 bits, and each possible combination of bits represents one real number.

Is IEEE 754 still used?

IEEE Standard 754 floating point is the most common representation today for real numbers on computers, including Intel-based PC's, Macs, and most Unix platforms. This is as simple as the name. 0 represents a positive number while 1 represents a negative number.

Why is the IEEE 754 standard important?

The standard specifies optional extended and extendable precision formats, which provide greater precision than the basic formats. An extended precision format extends a basic format by using more precision and more exponent range.

What will be IEEE 754 representation of?

The IEEE-754 standard describes floating-point formats, a way to represent real numbers in hardware. There are at least five internal formats for floating-point numbers that are representable in hardware targeted by the MSVC compiler. The compiler only uses two of them.


1 Answers

No, there does not exist a fully compliant IEEE754R implementation. Not only in Java, but in all currently available languages (Status July 2012).

EDIT: The poster asked for IEEE754 R support which is identical to IEEE 754-2008. If I want to add all reasons why there is no such thing, this would be long.

  • Traps: No, calling own routines with OVERFLOW, UNDERFLOW, INEXACT etc. with SIGFPE is not a trap. See IEEE754 (the old one) p. 21 for what constitutes a trap. Signaling NaNs. NaN payload access. Flag access. Enumerate languages which can do that.

  • Rounding modes: The new standard defines roundTiesToAway (p. 16) as new rounding mode. Unfortunately there are AFAIK no processors which supports this mode and no software emulation either.

  • Quad precision: Only supported in very few compilers and even less compilers which are not broken.

  • Densely packed Decimals: Will probably only supported in languages which use decimals, e.g. COBOL.

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

like image 121
Thorsten S. Avatar answered Sep 27 '22 21:09

Thorsten S.