1 year ago
#364934
Faraz Ahmed Qureshi
Strange result in deducting from a Decimal number Truncated or Floored version of the same
Upon trying in simple Console App, with a code like the following, the result found to be quite something unexpected as per the clip following in the end. Code Used
double A = 1234567.8991;
Console.WriteLine(Convert.ToString(A));
Console.WriteLine(Convert.ToString(A - Math.Truncate(A)));
Console.WriteLine(Convert.ToString(A - Math.Floor(A)));
Any reason for the said 0.899100000038743 appearing so as follows?
Since, it was only 0.8991, that was expected!
c#
rounding
truncate
decimal-point
floor
0 Answers
Your Answer