[LLVMdev] Floating-Point Overflow check
steffen.geissinger at googlemail.com
Mon Jul 26 04:12:07 PDT 2010
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.
So isn't there an easy way to check if one of those flags is set?
2010/7/23 John McCall <rjmccall at apple.com>
> On Jul 23, 2010, at 7:20 AM, Steffen Geißinger wrote:
> i need to check if an overflow of an floating-point arithmetic operation
> Currently I'm doing something like this (for addition):
> (LHS > 0 && RHS > 0 && sum <= 0) || (LHS < 0 && RHS < 0 && sum >= 0)
> IEEE floating-point doesn't overflow like this; if the magnitude of a
> result is too
> large to represent, it becomes an infinity rather than wrapping around like
> arithmetic. You want to check whether the result is infinite.
> I think the easiest way of doing that is to check whether (x - x) != (x -
- If you're talking about compile-time arithmetic, you should be using the
APFloat library, which figures this out for you.
No I'm talking about run-time.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev