I currently programming some calculations and found a weird issue, which I cannot explain. I'm doing a calculation which I save in a new double field. The thing is, that the finally saved value is not the same than the solution of the formula. I made a screenshot for better understanding.

When I put the whole calculation in a watch, I get the result "1.3050....." When i check the double afterwards, it has saved "2.87......." which I have no idea, where that comes from. Does anybody know, why it is behaving like this? For me thats absolutely unexplainable... enter image description here

Full size: https://i.stack.imgur.com/8nJpn.png

有帮助吗?

解决方案

Math.PI/180 should be Math.PI/180.0, dividing doubles by integers will cause some funny things to happen

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top