leehon
V2EX  ›  问与答

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

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