Why floating point value such as 3.14 are considered as double by default in MSVC?

前端 未结 5 1724
逝去的感伤
逝去的感伤 2020-11-27 08:27

Why do I need to put 3.14f instead of 3.14 to disable all those warnings ? Is there a coherent reason reason for this ?

5条回答
  •  有刺的猬
    2020-11-27 08:57

    Because double can approximate 3.14 much better than float, maybe? Here are the exact values:

    3.140000000000000124344978758017532527446746826171875 (double)

    3.1400001049041748046875 (float)

提交回复
热议问题