On Tue, Feb 15, 2011 at 3:27 AM, Casper Bang <[email protected]> wrote:
> On Feb 15, 10:40 am, Carl Jokl <[email protected]> wrote:
>> Is the x87 the most accurate general purpose floating point unit on
>> the market?
>
> This is the way I understand it:
>
> - Floating point data cannot be represented accurately as base-2
> (divided in significand and exponent).
> - IEEE 754 specifies floating point standard representation and
> operations with 64 bit double precision.
> - x87 tries to minimize the epsilon by internally computing with 80
> bit extended precision.
> - Other architectures operate with internal double precision resulting
> in greater epsilon (loss of precision).
> - You can instruct the x87 compiler to bypass extended precision mode
> (that's what the strictfp Java keyword does).
> - This bypass only applies to the significand, not the exponent - thus
> true IEE 754 interoperability cannot be achieved.
>
> Am I wrong?

The interoperability with "pure" 64-bit double can be achieved using
the x87 instructions, at the cost of some overhead.  This was a hot
issue in the Java world circa 1998 since for a time for there was no
known way to *exactly* implement Java's specified "write once, run
anywhere" floating-point semantics at a reasonable cost.  As written
up in the Java Grande document "Improving Java for Numerical
Computation"
http://math.nist.gov/javanumerics/reports/jgfnwg-01.html#floating-point
less expensive techniques were developed.  In brief, in addition to
the actual numerical operation, a store to memory is needed to
restrict the exponent range.  However, this can lead to double
rounding on underflow for multiply and divide.  The solution is to
scale down one operand of a multiply or divide by a specific power of
2 to preserve subnormal values, than scale back up to restore the
range before performing the store/reload.

The changes to Java's floating-point semantics made back in Java 1.2,
the strictfp modifier and a redefined default floating-point semantics
to allow extended exponents, were informed by those advancements in
x87 code generation.

As alluded to elsewhere on this thread, the x87 impedance mismatch
with java's semantics is mostly a moot point now as both Intel and AMD
have deprecated the x87 instructions and the SSE instructions
implement pure float/double operations.

Note that what the x87 does is fully IEEE 754 compliant, which is not
surprising since it predates and heavily influenced the IEEE 754
standard.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to