leehon
V2EX  ›  问与答

JS 乘法运算出现了浮点,该怎么解决

  •  
  •   leehon · Apr 2, 2016 · 2364 views
    This topic created in 3720 days ago, the information mentioned may be changed or developed.
    各位前端大人,一个是 20000 以内的任一整数,乘以固定的 0.99 。按道理说,怎么算也只有两位小数啊,有时候计算的结果还非常大,请问该怎么写
    2 replies    2016-04-02 05:19:34 +08:00
    binux
        1
    binux  
       Apr 2, 2016
    0.99*2
    1.98
    0.99*5432
    5377.68
    0.99*15432
    15277.68
    0.99*20000
    19800
    0.99*19999
    19799.01
    leehon
        2
    leehon  
    OP
       Apr 2, 2016
    @binux 谢谢,确定是其他地方出 bug 了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3801 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 79ms · UTC 10:28 · PVG 18:28 · LAX 03:28 · JFK 06:28
    ♥ Do have faith in what you're doing.