推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
bulabean
V2EX  ›  Python

来提个 Python 问题,以前一直没发现,相加的问题

  •  
  •   bulabean · Jul 25, 2017 · 2550 views
    This topic created in 3404 days ago, the information mentioned may be changed or developed.
    >>> 99.95+0.01+0.03+0.01
    Out: 100.00000000000001
    

    add

    有清楚原因的吗?来聊下

    4 replies  •  2017-07-25 11:44:31 +08:00
    matrixback
    matrixback
    Jul 25, 2017
    2
    浮点数的运算,涉及到底层,每个语言都有个问题吧。
    ipwx
    ipwx
    Jul 25, 2017
    3
    ![不损失精度的运算]( )

    你看,不损失精度的运算,也是很容易构造出来的。关键是你要明白,浮点数到底是什么……
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3569 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 10:03 · PVG 18:03 · LAX 02:03 · JFK 05:03
    ♥ Do have faith in what you're doing.