Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: "Tom Widmer [VC++ MVP]" <tom_usenet@xxxxxxxxxxx>
- Date: Tue, 29 Aug 2006 16:26:28 +0100
Dr Pizza wrote:
Sean M. DonCarlos wrote:
"John Carson" wrote:If the compiler doesn't then the compiler should leave well enough
The point is thatThey do. The compiler doesn't:
bool result = numeric_limits<float>::is_iec559;
sets result to true in VC++. This rather implies that VC++ floats
do have to adhere to IEC 559.
alone. If the compiler is too stupid to compute the value at compile
time then it should leave it to be evaluated at runtime (when it works).
There is no proscription against writing 1.0f / 0.0f in C++. The
compiler should not reject such an expression (provided that the
expression occurs in an appropriate place, of course).
Conforming compilers are required to reject the expression regardless of iec 559 support:
5/5
"If during the evaluation of an expression, the result is not mathematically defined or not in the range of representable values for its type, the behavior is undefined, unless such an expression is a constant expression (5.19), in which case the program is ill-formed."
That seems pretty clear to me. 1.0/0.0 is a constant expression, and hence a compiler error is expected. If that's not sufficient for you, then there's also this:
5.6/4
"The binary / operator yields the quotient, and the binary % operator yields the remainder from the division of the first expression by the second. If the second operand of / or % is zero the behavior is undefined;"
Tom
.
- References:
- C2124 is most disrespectful of IEEE floating point arithmetic
- From: Dr Pizza
- Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: Doug Harrison [MVP]
- Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: Dr Pizza
- Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: Abdo Haji-Ali
- Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: Dr Pizza
- Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: Victor Bazarov
- Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: John Carson
- Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: Dr Pizza
- C2124 is most disrespectful of IEEE floating point arithmetic
- Prev by Date: Re: C2124 is most disrespectful of IEEE floating point arithmetic
- Next by Date: Re: resource leaks in CreateSolidBrush() and DeleteObject( hBrush
- Previous by thread: Re: C2124 is most disrespectful of IEEE floating point arithmetic
- Next by thread: Re: C2124 is most disrespectful of IEEE floating point arithmetic
- Index(es):
Relevant Pages
|