Why is there a rounding difference between my normal recursion and tail recursion example?
问题 While toying with a tail recursion example I noticed a small discrepancy between the results of a normal recursive call and a tail recursive call: scala> def fact(n: Int): Double = if(n < 1) 1 else n * fact(n - 1) fact: (n: Int)Double scala> fact(30) res31: Double = 2.6525285981219103E32 scala> @tailrec def fact(n: Int, acc: Double = 1): Double = if(n < 1) acc else fact(n - 1, n * acc) fact: (n: Int, acc: Double)Double scala> fact(30) res32: Double = 2.652528598121911E32 Just out of curiosity