Strange result with floating point addition

前端 未结 4 1616

Why is it when I print/display the result of

eval(\"11.05\") + eval(\"-11\")

it comes out as 0.05000000000000071 instead of the expecte

4条回答
  •  悲&欢浪女
    2020-12-11 23:50

    This has nothing to do with eval (which you should avoid).

    You get the same problem with 11.05 - 11.

    This is just the usual floating point problem

提交回复
热议问题