Issue
I want to add precision to the decimal value. For example, I have this value:
decimal number = 10;
I want to make it 10.00
. I don't want to convert it to string
like number.ToString("#.00")
Currently, I have this method:
decimal CalculatePrecision(decimal value, int precision)
{
var storedCalculated = decimal.Divide(1, Convert.ToDecimal(Math.Pow(10, precision)));
return value + storedCalculated - storedCalculated;
}
Is there any good solution for this?
Solution
You can't. 10 and 10.00 are the same number. Only the "presentation" is different. Both "presentations" are strings. The actual number look different. If you need to change the presentation, convert to string.
Answered By - EricSchaefer Answer Checked By - Terry (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.