Literals/Integer: Difference between revisions

m
Updated C#
No edit summary
m (Updated C#)
Line 275:
Literals of either form can be suffixed with <code>U</code> and/or <code>L</code>. <code>U</code> will cause the literal to be interpreted as an unsigned type (necessary for numbers exceeding 2<sup>31</sup> or hex literals that have a first digit larger than <code>7</code>) and <code>L</code> signifies the use of a <code>long</code> type – using <code>UL</code> or <code>LU</code> as suffix will then use <code>ulong</code>. C# has no syntactic notion of expressing integer literals of smaller types than <code>Int32</code>; it is a compile-time error to have an assignment such as
<lang csharp>byte x = 500;</lang>
'''Update'''<br/>
As of C#7, integer literals can be written in binary with the prefix <code>0b</code>. Furthermore, underscores can be used as separators:
<lang csharp>
int x = 0b1100_1001_1111_0000;
</lang>
 
=={{header|C++}}==
196

edits