Alexisused
V2EX  ›  问与答

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

  •  
  •   Alexisused · Oct 16, 2017 · 2047 views
    This topic created in 3156 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   ·   4092 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 05:18 · PVG 13:18 · LAX 22:18 · JFK 01:18
    ♥ Do have faith in what you're doing.