Thread: Detecting +/-1.#J

  1. #1
    george7378
    Guest

    Detecting +/-1.#J

    Hi everyone,

    How do I detect when the answer to a sum is infinity? I need to implement it into the following code:

    Code:
    if (Number == (Infinity))
        MessageBox(hwnd, "Enter a number above zero.", "Error", MB_OK);
        break;
    It is a division sum.

    Thanks.

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    See fpclassify or isinf ;-). The latter does just that.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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);
    //}

  4. #4
    george7378
    Guest
    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.

  5. #5
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    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)) ...;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Detecting Keys
    By Sn0wcra5h in forum C Programming
    Replies: 1
    Last Post: 01-21-2010, 11:18 PM
  2. Detecting Edit Control Text
    By yoonkwun in forum Windows Programming
    Replies: 2
    Last Post: 07-12-2009, 08:48 AM
  3. functions and passing data
    By redmondtab in forum C Programming
    Replies: 41
    Last Post: 09-21-2006, 12:04 PM
  4. Detecting the OS
    By John.H in forum C++ Programming
    Replies: 3
    Last Post: 02-21-2003, 09:50 AM
  5. Detecting CD drive letters in the Win32 API...
    By SyntaxBubble in forum Windows Programming
    Replies: 1
    Last Post: 10-07-2002, 02:20 AM