I have calculation statement in C# as below statement:
(-0.0116 * (5.08 - 0.52 * Math.Pow(5.08, 1.3)) * Math.Pow(0.5, 1.1) * (-0.14 * Math.Pow((19000 * 0.5), 0.8)))
When I debug and add this statement to watch, it was shows as below screenshot:
but when assign to double variable, the result was changed:
How do I get 0.89713135944117184
without changing any of the implementation?
The maximum precision of a double in C# is 15 or 16 digits. See the reference here .
You should use BigInteger
, assuming you are using .Net 4+. BigInteger
"Represents an arbitrarily large signed integer." See the BigInteger
documentation here .
See this answer for an example implementation that uses the BigInteger
class to do decimal based calculations.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.