为什么 f 放在浮点值之后?

2022-01-09 00:00:00 floating-point java

我不知道为什么在Java或其他语言中f或F放在浮点值之后?例如,

I don't know why f or F is placed after float values in Java or other languages? for instance,

float fVariable = 12.3f;

除了表明这是一个浮点值之外的任何特征?

any features other than indicating that this is a float value?

推荐答案

默认情况下 12.3double 字面量,所以告诉编译器把它当作 float 显式 -> 它使用 fF

by default 12.3 is double literal, So to tell compiler to treat it as float explicitly -> it uses f or F

相关文章