The function has passed the string "1004233" and prints the following output:
D1 = 1.004233
D2 = 0.00423299999999993
D3 = 4232.99999999993
D4 = 4232
I do not need to print 4233 and 4232 to D4. How do I stop this exact loss?
public string someFunc (string s) {string retval = "0"; Try {int id = int.Parse (s); Double D = (double) ID / (double) 1000000; Console.light line ("D1 =" + D); D = D - Mathematics. Transcut (d); Console Weedline ("D2 =" + D); D = D * (double) 1000000; Console.light line ("d3 =" + d); Retval = "" + Math Tranquet (d); Console.light line ("D4 =" + retal); } Hold (Exception Pre) {} Return Retval; }
This is
A decimal instead
. However, even with decimal
s is not infinitely accurate, they have been implemented in base 10, so they will give you expected results.
Comments
Post a Comment