why Floating point exception?

Posted by livio8495 on Stack Overflow See other posts from Stack Overflow or by livio8495
Published on 2010-03-16T11:24:08Z Indexed on 2010/03/16 11:26 UTC
Read the original article Hit count: 130

Filed under:

I have a floating point exception, and I don't know why.

the code is this:

void calcola_fitness(){

    vector<double> fitness;
    int n=nodes.size();
    int e=edges.size();
    int dim=feasibility.size();
    int feas=(feasibility[dim-1])*100;
    int narchi=numarchicoll[dim-1]/e;
    int numero_nodi=freePathNode.size()/n;
    double dist_start_goal=node_dist(0,1);
    int i,f,t;
    double pathlenght=0;
    int siize=freePathNode.size();
    for(i=0;i!=siize-1; i++){
    f=freePathNode[i].getIndex();
    i++;
    t=freePathNode[i].getIndex();
    i--;
    pathlenght=pathlenght+node_dist(f,t);
    }

    double pathlenghtnorm=pathlenght/10*dist_start_goal;
    double fit=((double)numero_nodi+pathlenghtnorm+(double)narchi)*((double)feas);
    fitness.push_back(fit);
    }

Could anybody help me? What's the problem? I could I solve this? thank you very much

© Stack Overflow or respective owner

Related posts about c++