English 中文(简体)
是否有任何C++风格的指南,可以谈论数字字面上的uff子?
原标题:Is there any C++ style guide that talks about numeric literal suffixes?

在我读过的所有C++风格指南中,我从未看到过任何关于数字字面图的信息(即3.14f0L等)。

<<>问题>

  1. 是否有任何风格的指南可以说明关于使用该方法的会谈,或是否有一般性公约?

  2. 我偶尔在制图中见到<代码>f。 方案拟订领域的使用是否有任何趋势?

最佳回答

我没有发现的一般风格指南。 我用英文大写字母附加数字编号。 我也用适当的颜色来形容整体。

我假定你知道这些图象意味着什么:3.14F是一个float,字面上是12.345,字面是两字面,6.66L是一字面长。

ger:U。 <代码>U和之间的次序 L don t matter,但我总是带UL。 例如,我宣布这些变量为<代码>。

如果你将一种类型的变数定为另一种类型的字面,或者为另一种类型的功能论证提供一种类型的数字字面。 采用适当的颜色避免了这种情况,并且与静态预测一样有用,有助于挑出。 始终如一地使用数字字面图是好的风格,避免了数字的意外。

People differ on whether lower or upper case is best. Pick a style that looks good to you and be consistent.

问题回答

我知道的唯一既定公约(有些已经确定,有的)是永远使用<代码>L而不是l<>/code>,以避免在<1>上被误入。 除此之外,它还非常需要使用你所需要的东西。

还指出,C++11允许用户界定的字面与用户界定的颜色。

The CERT C Coding Standard recommends to use uppercase letters:

DCL16-C. Use "L," not "l," to indicate a long value

下几封信(1)很容易与数字1(一)混为一谈。 这一点特别令人困惑,因为它表明愤怒的字面不变具有长期价值。 该建议与DCL02-C. 使用直观识别符号相似。

同样,你在表示愤怒的字面不变是长期价值时,应当使用LL而不是低地壳。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签