简体   繁体   English

f和F有什么区别

[英]What is the difference between f and F

In the following code, the const are defined using two different ways. 在以下代码中,const使用两种不同的方式定义。

     const float KS = 0.001F;
     const float WW = 0.001f;

Is there any difference between F and f? F和f之间有什么区别吗?

Revision 1: If both are same then why both cases are allowed ? 修订版1:如果两者相同,为什么允许两种情况?

Nope, no difference between f and F in this case. 不,在这种情况下, fF之间没有区别。 It's the special suffix for float literals, either works fine. 它是float文字的特殊后缀,可以正常工作。

With the long literals, there's stylistic difference: l (lowercase) looks a lot like 1 (the number one). 随着long文字,有风格差异: l (小写)看起来很像1 (第一)。 It's recommended to use capital L for long literals. 建议使用大写L来表示long文字。

References 参考

  • MSDN/C# Programmer's Reference/float MSDN / C#程序员参考/浮点数

    By default, a real numeric literal on the right-hand side of the assignment operator is treated as double . 默认情况下,赋值运算符右侧的实数数字文字被视为double Therefore, to initialize a float variable use the suffix f or F . 因此,要初始化float变量,请使用后缀fF

  • MSDN/C# Programmer's Reference/long MSDN / C#程序员参考/长

    You can also use the lowercase letter "l" as a suffix. 您也可以使用小写字母"l"作为后缀。 However, this generates a compiler warning because the letter "l" is easily confused with the digit "1" . 但是,这会生成编译器警告,因为字母"l"很容易与数字"1"混淆。 Use "L" for clarity. 为清楚起见,请使用"L"

Yes, the case :) Functionality wise, no. 是的,案例:)功能明智,没有。 Its the same as String and string . 它与Stringstring相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 object [] = object [] f = new object []和var f = new []之间的区别? - The difference between object[] = object[] f = new object[] and var f = new []? Point vs MCvPoint2D64f,它们有什么区别? - Point vs MCvPoint2D64f, What is the difference between them? Vector_Point_to_Mat和Vector_Point2f_to_Mat有什么区别 - What's the difference between Vector_Point_to_Mat and Vector_Point2f_to_Mat C#中的委托与F#中的第一类值有什么区别? - What is the difference between delegates in C# and functions as first class values in F#? 在控制台上使用shift-f5或red-X终止调试会话有什么区别? - what is the difference between using shift-f5 or the red-X on the controlbox for terminating a debug session? Visual Studio Dom Explorer和IE F12工具Dom Explorer之间的区别 - Difference between Visual Studio Dom Explorer and I.E. F12 tools Dom Explorer 为什么LINQ(c#)与Seq(f#)之间存在性能差异 - Why is there a performance difference between LINQ (c#) vs Seq (f#) C#扩展方法和F#管道转发操作符之间有什么关系? - What is the relation between C# extension methods and the F# pipe-forward operator? 使用WCF和F#的进程之间的通信 - Communication between processes using WCF and F# GC 用于 F# 和 C# 之间的互操作 - GC for interop between F# and C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM