why do I get garbage value when I do this?
int main(){
double shareOutstanding = 3.0000000;
double percentageToSell = 0.3542101;
percentageToSell *= 10;
percentageToSell -= shareOutstanding; //should be 3.542101 - 3.000000
cout << setprecision(16) << percentageToSell << endl;
}
It outputs the value I want but with garbage value at the end. output: .5421010000000002 (The 2 at the end is garbage.)
instead of: .542101 (The value I really want.)
I think the "percentageSell *= 10;" part screws it up. I NEED this line however.
help please.