0

In java, why is the value of log(3)243 not 5 but 4.9999999

public class Log{
public static void main(String[] args) {
for(int i=3;i<7652;i=i*3)
System.out.println(i+"    "+Math.log(i)/Math.log(3));
}
}

The output for the following code is:

27    3.0
81    4.0
243   4.999999999999999
729   6.0
2187  7.0
6561  8.0
Zoltán Ujhelyi
  • 13,788
  • 2
  • 32
  • 37
arnav bhartiya
  • 303
  • 1
  • 3
  • 9

0 Answers0