I have a value being stored in the database with an implied decimal. e.g. 1234 is 12.34, 456 is 4.56.
Unfortunately due to the amount of code around the implied decimal column, under the current request it is not feasible to change the database's implied decimal to a real decimal.
The issue I'm having is in converting the implied decimal to a "real" decimal works on my local machine, but is not when deployed to our next environment.
9999 in my environment correctly converts to 99.99, however the same would convert to 99.9899978637695 in our next environment.
Here's the code I'm using:
public string FormatForDisplay(string valueFromDb)
{
double convertedNumber;
double.TryParse(valueFromDb, out convertedNumber);
return ConvertImpliedDecimalToPercent(convertedNumber).ToString();
}
public double ConvertImpliedDecimalToPercent(double convertedNumber)
{
return convertedNumber / 100;
}
I have been unable to reproduce the issue locally, so i'm not sure how to test that it's fixed. I guess my question is why does this occur, and is there a way to fix it?