What's the use of suffix `f` on float value

前端 未结 7 614
失恋的感觉
失恋的感觉 2020-11-28 04:25

I am wondering what the difference is between these two variables in C:

float price = 3.00;

and

float price = 3.00f;
         


        
7条回答
  •  不知归路
    2020-11-28 05:21

    3.00 is interpreted as a double, as opposed to 3.00f which is seen by the compiler as a float.

    The f suffix simply tells the compiler which is a float and which is a double.

    See MSDN (C++)

提交回复
热议问题