Hi everyone,
How do I detect when the answer to a sum is infinity? I need to implement it into the following code:
It is a division sum.Code:if (Number == (Infinity)) MessageBox(hwnd, "Enter a number above zero.", "Error", MB_OK); break;
Thanks.
This is a discussion on Detecting +/-1.#J within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, How do I detect when the answer to a sum is infinity? I need to implement it into ...
Hi everyone,
How do I detect when the answer to a sum is infinity? I need to implement it into the following code:
It is a division sum.Code:if (Number == (Infinity)) MessageBox(hwnd, "Enter a number above zero.", "Error", MB_OK); break;
Thanks.
See fpclassify or isinf ;-). The latter does just that.
Why not check if the denominator is zero before dividing?
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
Thanks.
I tried the check for 0, but it didn't seem to work for division sums.
Please could you show me how to use the isinf() operation?
Thanks.
Last edited by george7378; 05-17-2010 at 11:15 AM.
Well, look up a reference for that - you should really have one. Or use an online one, there are plenty. Basically, it's very simple: if (isinf(num)) ...;