tan 45 gives me 0.9999
问题 Why does tan 45 (0.7853981633974483 in radian) give me 0.9999 ? What's wrong with the following code? System.out.println(Math.tan(Math.toRadians(45.0)) ); I don't think there's any typo in here. So what's the solution here? 回答1: Floating point calculations will often lead to such inaccuracies. The problem is that numbers cannot be accurately represented within a fixed number of bits. To give you another example (in decimal), we all agree that 3 * (1/3) = 1 . However, if your calculator only