<div> </div>
<div>
<div>Hello,</div>
<div> </div>
<div>i know that the result is infinte, but there are sill flags in the FPU which indicate that an overflow, underflow or div by zero occured.</div>
<div>So isn't there an easy way to check if one of those flags is set?</div>
<div><br> </div></div>
<div class="gmail_quote">2010/7/23 John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>></span><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div style="WORD-WRAP: break-word">
<div>
<div class="im">
<div>On Jul 23, 2010, at 7:20 AM, Steffen Geißinger wrote:</div>
<blockquote type="cite">
<div><font color="#000000">i need to check if an overflow of an floating-point arithmetic operation occured.</font></div>
<div><font color="#000000">Currently I'm doing something like this (for addition):</font></div>
<div><font size="2"><font color="#000000" size="2"></font></font> </div>
<div><font size="2"><font color="#000000" size="2">(LHS > 0 && RHS > 0 && sum <= 0)  || (LHS < 0 && RHS < 0 && sum >= 0)</font></font></div></blockquote>
<div><br></div></div>IEEE floating-point doesn't overflow like this;  if the magnitude of a result is too</div>
<div>large to represent, it becomes an infinity rather than wrapping around like integer</div>
<div>arithmetic.  You want to check whether the result is infinite.</div>
<div><br></div>
<div>I think the easiest way of doing that is to check whether (x - x) != (x - x).</div>
<div><br></div><font color="#888888">
<div>John.</div></font></div></blockquote></div>
<p><br> - If you're talking about compile-time arithmetic, you should be using the APFloat library, which figures this out for you.</p>
<div>No I'm talking about run-time.</div>
<div> </div>
<div>-- Steffen</div>