Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: "Dr Pizza" <DrPizza@xxxxxxxxxxxxxxxxx>
- Date: Wed, 13 Sep 2006 09:42:12 -0700
Tom Widmer [VC++ MVP] wrote:
Dr Pizza wrote:Er, if traps are disabled (which IEC 559 allows) then IEC 559
Actually, IEC 559 makes no such guarantee. 1.0/0.0 produces a
division by zero exception, which may cause a trap depending on
whether a trap handler is set up (which it apparently is in the
compiler!).
explicitly guarantees the result. If the compiler has traps enabled
thereby preventing it from compiling programs whose semantics are
well-defined and legal the the compiler is at fault IMO.
In addition, IEC 559 does not define how source code mapsThe C++ compiler shouldn't trap perfectly sound expressions.
onto floating point operations, and nor does the C++ standard for
that matter, so that's really up to the compiler (and indeed, some
compilers use extended precision registers for intermediate
operations, etc.).
Regarding the case where the double isn't a global (and therefore the1.0 / 0.0 is a perfectly good IEC 559 alternative.
initializer isn't a constant-expression), I agree that MS would be
better to define their undefined behaviour as returning +inf, but at
least the error forces you to be explicit, and use infinity() when
you mean it.
--
.
- Prev by Date: Re: Calling get_Version from a C program
- Next by Date: Re: Cost of dynamic_cast
- Previous by thread: Cost of dynamic_cast
- Next by thread: Passing a string back to VB
- Index(es):
Relevant Pages
|
Loading