V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · 2157 views
    This topic created in 3198 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
        2
    matrixback  
       Jul 25, 2017
    浮点数的运算,涉及到底层,每个语言都有个问题吧。
    ipwx
        3
    ipwx  
       Jul 25, 2017
    ![不损失精度的运算]( )

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