Alexisused
V2EX  ›  问与答

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

  •  
  •   Alexisused · Oct 16, 2017 · 2118 views
    This topic created in 3191 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   ·   4055 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 04:16 · PVG 12:16 · LAX 21:16 · JFK 00:16
    ♥ Do have faith in what you're doing.