简体   繁体   中英

What is the difference between f and F

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.

References

  • 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 suffix f or F .

  • 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.

Yes, the case :) Functionality wise, no. Its the same as String and string .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM