IEEE floating point numbers

  • Thread starter Thread starter Andre
  • Start date Start date
A

Andre

I read some place that for performance reasons, IEEE floating point
standard has not been implemented by .NET and that different machine
architectures may produce different results.. but what if our
requirements is to produce the same results using the IEEE standard on
different machines? Is there no way of doing this (like the strictfp
construct in Java)? Thanks


-Andre
 
Simon Trew said:
OK gotcha. Yes, there is that limitation. I vaguely recall there is a
setting for this, but I am just back from a short holiday so the old noggin
is not up to full speed yet.

I suppose you could try to get round it by putting the intermediate results
of calculations back into variables, so that the 80-to-64 truncation will
occur each time. Of course I realise this particular problem was just a
f'rinstance, & also that you'd probably have to do some horrible stuff to
stop it being optimized away by the C# compiler or the JITter.

No, temporary variables won't help - I *suspect* (although I don't
know) that each result *is* truncated to 64 bits. The point is that the
CPU is effectively converting each 64 bit operand into 80 bits, then
doing the operation, then converting the result back into 64 bits. That
will sometimes give a different result from doing the whole thing in 64
bits. I'll try to come up with a specific example if you like. (It'll
take a while though!)
 
Exactly. The CPU is operating on 80 bits while the result gets truncated
to 64 bits. This could give different results on architectures that
perform floating point operations on 64-bits or even 128 bits. I was
wondering if there's a 'cleaner' way of stopping this, but I suspect
there isn't. Thanks anyways guys.

-Andre
 
Back
Top