I am making a Windows Phone 8.1 App and I am trying to make a money counting function. I want to know if the variable has 1 decimal or 2 or more.
double 1decimal = 0.2;
double 2decimalsOrMore = 0.33333;
I need some kind of "if-statement" that checks if the variable has 1 or more decimals. If it has 1 decimal I need it to have 2 decimals by adding "0" to the double
if ("code here){
// has 1 decimal
string StringnewDecimalValue = oldDecimalValue + "0";
double newDecimalValue = double.parse(newDecimalValue);
}
else{
// has 2 decimals or more
double newDecimalValue = Math.Round(oldDecimalValue , 2);
}
Basically, if the endresult (money) has 1 decimal (something like $1.2) it needs to be $1.20