What do F and D mean at the end of numeric literals?

后端 未结 6 2024
离开以前
离开以前 2020-11-28 13:56

I\'ve seen some of this symbols, but I cannot find anything strange with it,

double d = 5D;
float f = 3.0F;

What does the D and F behind 5

6条回答
  •  渐次进展
    2020-11-28 14:55

    D stands for double and F stands for float. You will occasionally need to add these modifiers, as 5 is considered an integer in this case, and 3.0 is a double.

提交回复
热议问题