Anyone can explain?, why a string change value when I convert a floating number to a string .its like that when I convert a floating number (34.567) to a string. it converts as "34.5679987", something like that. How I can get actual string;
#include <bits/stdc++.h>
using namespace std;
string find_floating(string str) {
int find = str.find(".");
if (find == -1) {
return "00";
} else {
str = str.substr(find + 1);
}
return str;
}
main() {
float num;
cout << "enter number : ";
cin >> num;
string str = to_string(num);
cout << str << endl;
cout << typeid(str).name() << endl;
cout << find_floating(str);
}