Unexpected loss of precision when dividing doubles

前端 未结 8 1970
慢半拍i
慢半拍i 2021-02-09 14:33

I have a function getSlope which takes as parameters 4 doubles and returns another double calculated using this given parameters in the following way:

double QSw         


        
8条回答
  •  被撕碎了的回忆
    2021-02-09 15:17

    While the academic discussion going on is great for learning about the limitations of programming languages, you may find the simplest solution to the problem is an data structure for arbitrary precision arithmetic.

    This will have some overhead, but you should be able to find something with fairly guaranteeable accuracy.

提交回复
热议问题