1.#inf00000

This is a discussion on 1.#inf00000 within the C++ Programming forums, part of the General Programming Boards category; Hi all. I am having a problem with my output for the followig function: Code: void degree_membership(int index[cluster_num], int count1) ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    5

    1.#inf00000

    Hi all.

    I am having a problem with my output for the followig function:

    Code:
    void degree_membership(int index[cluster_num], int count1)
    {
            lower[count1] = 0.0;
    	for(i = 0; i < ROW; i++)
       {
          upper_euc[count1][i]= 1 / euc_total[count1][i];
          lower[count1] = lower[count1] + upper_euc[count1][i];
          printf("Lower: %lf\n", lower[count1]);
       }
    }
    When I try to printf the value for lower[count1], it returns 1.#INF00000 values for each loop iteration.

    Why this happen? Can anyone help me with this prob?

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    When I try to printf the value for lower[count1], it returns 1.#INF00000 values for each loop iteration.

    Why this happen? Can anyone help me with this prob?

    Thanks in advance.
    Are you dividing by 0 somewhere? 1 / euc_total[count1][i] looks suspicious. If euc_total[count1][i] == 0 you'll divide by 0 and get either positive or negative infinity (IEEE used on most machines). Then, when you add this value to lower[count1] you'll set lower[count1] to infinity and infinity will be printed.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    That's a C program, and this is the C++ forum.

    Try changing this line
    Code:
    upper_euc[count1][i]= 1 / euc_total[count1][i];
    to
    Code:
    if(upper_euc[count1][i]) upper_euc[count1][i]= 1 / euc_total[count1][i];
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21