Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: "Dr Pizza" <DrPizza@xxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Aug 2006 12:24:50 -0700
Alexander Grigoriev wrote:
In the standard:
"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 illformed.
[Note: most existing implementations of C++ ignore integer overflows.
Treatment of division by zero, forming a remainder using a zero
divisor, and all floating point exceptions vary among machines, and
is usually adjustable by a library function. ]"
Clause 5.119.3:
An arithmetic constant expression shall have arithmetic or
enumeration type and shall only have operands that are integer
literals (2.13.1), floating literals (2.13.3), enumerators, character
literals (2.13.2) and sizeof expressions (5.3.3). Cast operators in
an arithmetic constant expression shall only convert arithmetic or
enumeration types to arithmetic or enumeration types, except as part
of an operand to the sizeof operator.
This means: 1.f/0.f is a constant expression and the compiler is
evaluating it on compile time. Since it's not mathematically defined
(don't mind it's defined by IEC559), the program is illformed.
What are you talking about? According to the mathematical rules for
floating point numbers (which are NOT the rules for real numbers) the
result is both defined and representable.
--
.
- Follow-Ups:
- Re: C2124 is most disrespectful of IEEE floating point arithmetic
- From: Abdo Haji-Ali
- Re: C2124 is most disrespectful of IEEE floating point arithmetic
- 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: Alexander Grigoriev
- C2124 is most disrespectful of IEEE floating point arithmetic
- Prev by Date: Re: Build registered dll's
- Next by Date: Re: C2124 is most disrespectful of IEEE floating point arithmetic
- 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
|