add two double given wrong result

前端 未结 5 1100
被撕碎了的回忆
被撕碎了的回忆 2021-01-22 10:33

I\'m using the following piece of code and under some mysterious circumstances the result of the addition is not as it\'s supposed to be:

double _west = 9.482935         


        
5条回答
  •  有刺的猬
    2021-01-22 11:03

    The problem is that Double only has precision of 15 - 16 digits (and you seem to need more precision in your example) whereas Decimal has precision to 28 - 29. How are you converting between Double and Decimal?

提交回复
热议问题