Dear friends, I discovered a bug with logaritmic function. log(1000, 10) gives 2.9999999999999996 in place of 3.0 Thanks a lot. U.V ( ultraviolet )
This is probably a reason for the gaps in floating point numbers. See: https://docs.python.org/3/tutorial/floatingpoint.html The floating point numbers in computer programs are not truly continues (in mathematical context), so there exists gaps between two subsequent numbers. And with many iterations of some arithmetic operation, the different may become significant. Thanks
On 17. 12. 22 16:42, Ugur VARLIKLI wrote:
Dear friends,
I discovered a bug with logaritmic function.
log(1000, 10) gives 2.9999999999999996 in place of 3.0
Hello, This is due to floating point inaccuracy, see here: https://docs.python.org/3/tutorial/floatingpoint.html The plain log function uses base *e* logarithms, `log(1000)/log(10)` in this case. The intermediate values contribute to the rounding error. You can use `math.log10(1000)` for a more accurate base10 logarithm, see: https://docs.python.org/3/library/math.html#math.log10
participants (3)

Petr Viktorin

Sharif Mehedi

Ugur VARLIKLI