Haskell: Unexpected output for expression [0, 0.1 .. 1]

前端 未结 2 1288
臣服心动
臣服心动 2020-12-11 04:21

When evaluating the expression:

*main> [0, 0.1 .. 1]

I was actually expecting:

 [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0         


        
2条回答
  •  情歌与酒
    2020-12-11 04:56

    Refer to this other post. As it states, floating point numbers aren't precise in the CPU.

提交回复
热议问题