I had some questions about putting f next to literal values. I know it defines it as a float but do I really need it? Is this 2.0f * 2.0f any faster or compiled any different than 2.0 * 2.0? Is a statement like float a = 2.0; compiled differently than float a = 2.0f;?
f
float
2.0f * 2.0f
2.0 * 2.0
float a = 2.0;
float a = 2.0f;
Sometimes you need it to explicitly have type float, like in the following case
float f = ...; float r = std::max(f, 42.0); // won't work; (float, double). float r = std::max(f, 42.0f); // works: both have same type
1.4m articles
1.4m replys
5 comments
57.0k users