skulkarni
July 21st, 2002, 03:50 PM
Hi, I am working with c++ on linux and i got an error while running the program and the below code is a part of it.
float last_dist = matrix_distance(at_place_id, item.end_place);
float value = (item.score / ( item.time_spent + (last_dist / item.mph) + item.time_from_end_to_mth + item.total_distance + last_dist + item.dist_from_end_to_mth));
when i executed the code, i got the NaN error. and when i changed the code to
float last_dist = matrix_distance(at_place_id, item.end_place);
float fmph = (float)item.mph;
float tot_time = item.time_spent + (last_dist / fmph) + item.time_from_end_to_mth;
float tot_dist = item.total_distance + last_dist + item.dist_from_end_to_mth;
float fscore = (float)item.score;
float den = tot_dist + tot_time;
float value = fscore / den;
the error is gone.
What may be the reason for it. why do we get Nan errors and how to remove them.
Thanks.
Srinivas.
float last_dist = matrix_distance(at_place_id, item.end_place);
float value = (item.score / ( item.time_spent + (last_dist / item.mph) + item.time_from_end_to_mth + item.total_distance + last_dist + item.dist_from_end_to_mth));
when i executed the code, i got the NaN error. and when i changed the code to
float last_dist = matrix_distance(at_place_id, item.end_place);
float fmph = (float)item.mph;
float tot_time = item.time_spent + (last_dist / fmph) + item.time_from_end_to_mth;
float tot_dist = item.total_distance + last_dist + item.dist_from_end_to_mth;
float fscore = (float)item.score;
float den = tot_dist + tot_time;
float value = fscore / den;
the error is gone.
What may be the reason for it. why do we get Nan errors and how to remove them.
Thanks.
Srinivas.