Java (and other languages) Problem When Calculating Logarithisms

Опубликовано: 08 Июль 2026
на канале: JTECH
29
0

In this video, I talk about a problem that I encountered when calculating log with base 3. The issue arose when using Math.log(n)/Math.log(3), it gave a slightly offset answer. Surprisingly, using Math.log10(n)/Math.log10(3) solved the issue.

Most probably this occurs due to the way doubles are stored and to some rounding at the bit level. I'd like to know your thoughts on this