Alexisused
V2EX  ›  问与答

请问, js 浮点数精度问题的正确处理方式是什么?

  •  
  •   Alexisused · Oct 16, 2017 · 2019 views
    This topic created in 3143 days ago, the information mentioned may be changed or developed.

    例如 0.1 + 0.2 = 0.30000000000000004 这种,到底应该怎么处理呢, 如何才能得到准确的结果呢

    ineed
        1
    ineed  
       Oct 16, 2017 via iPhone
    (0.1*10+0.2*10)/10 这样可以吗?我一般这样做
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   940 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 21:01 · PVG 05:01 · LAX 14:01 · JFK 17:01
    ♥ Do have faith in what you're doing.