In the following code, the const are defined using two different ways.
const float KS = 0.001F;
const float WW = 0.001f;
Is there any difference between F and f?
Revision 1: If both are same then why both cases are allowed ?
Nope, no difference between f
and F
in this case. It's the special suffix for float
literals, either works fine.
With the long
literals, there's stylistic difference: l
(lowercase) looks a lot like 1
(the number one). It's recommended to use capital L
for long
literals.
MSDN/C# Programmer's Reference/float
By default, a real numeric literal on the right-hand side of the assignment operator is treated as
double
. Therefore, to initialize a float variable use the suffixf
orF
.
MSDN/C# Programmer's Reference/long
You can also use the lowercase letter
"l"
as a suffix. However, this generates a compiler warning because the letter"l"
is easily confused with the digit"1"
. Use"L"
for clarity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With