Inaccurate Logarithm in Python

前端 未结 9 1947
甜味超标
甜味超标 2020-12-04 01:37

I work daily with Python 2.4 at my company. I used the versatile logarithm function \'log\' from the standard math library, and when I entered log(2**31, 2) it returned 31.0

9条回答
  •  情深已故
    2020-12-04 02:03

    You should read "What Every Computer Scientist Should Know About Floating-Point Arithmetic".

    http://docs.sun.com/source/806-3568/ncg_goldberg.html

提交回复
热议问题