推荐学习书目
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
dimtutac
V2EX  ›  Python

/ 然后 math.floor 和 // 结果不一致……求教数据格式转换机制

  •  
  •   dimtutac · Nov 16, 2024 · 2900 views
    This topic created in 578 days ago, the information mentioned may be changed or developed.
    Python 3.11.7 (main, Sep 15 2024, 15:14:54) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 1e19 / 1043
    9587727708533078.0
    >>> 1e19 // 1043
    9587727708533078.0
    >>> 1e19 // 1044
    9578544061302680.0
    >>> 1e19 / 1044
    9578544061302682.0
    

    wolfram 算出来是 9.578544061302681 × 10^15 即 9578544061302681

    int 和 float 是在什么时候转换的呢

    =============补充下背景

    在刷 atcoder https://atcoder.jp/contests/abc380/editorial/11362?lang=en

    用 a//b ac 了,但是 math.floor(a/b)去实现就无法 ac 然而如果 a//b 精度有问题,那是否说明 a//b 的 ac 也只是巧合……

    nagisaushio
        1
    nagisaushio  
       Nov 17, 2024
    你需要 10**19//1044
    dimtutac
        2
    dimtutac  
    OP
       Nov 17, 2024
    @nagisaushio 懂了,感谢。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2670 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 12:06 · PVG 20:06 · LAX 05:06 · JFK 08:06
    ♥ Do have faith in what you're doing.