I use atof() in a function but i get stranges values..
when converted I get the following:
3.4
3.39999999999999991118215802999
3.3
3.29999999999999982236431605998
3.2
3.20000000000000017763568394002
2.1
2.10000000000000008881784197001
what is wrong here? atof() itself?Code:string temp_num = ""; char dot = '.'; while ((isdigit(temp_string[n])) || (temp_string[n] == dot)) temp_num += temp_string[n++]; number_value = atof(temp_num.c_str());
I also tried atol() but it wouldnt convert to decimal?
I know someone else asked the same question but using a correction factor in my case wont solve my problem..