tan 45 gives me 0.9999

前端 未结 4 698
清酒与你
清酒与你 2021-01-12 08:30

Why does tan 45(0.7853981633974483 in radian) give me 0.9999? What\'s wrong with the following code?

System.out.println(Math.tan(M         


        
4条回答
  •  死守一世寂寞
    2021-01-12 09:08

    That's probably because tan(45) is 1, and the rest is a rounding error. Floating point calculations are highly unlikely to give you accurate results, due to how floating point calculations work.

提交回复
热议问题