A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/dotnet/roslyn/issues/215 below:

Binary literals · Issue #215 · dotnet/roslyn · GitHub

There’s a relatively common request to add binary literals to C# and VB. For bitmasks (e.g. flag enums) this seems genuinely useful, but it would also be great just for educational purposes.

Binary literals would look like this:

Syntactically and semantically they are identical to hexadecimal literals, except for using b/B instead of x/X, having only digits 0 and 1 and being interpreted in base 2 instead of 16.

There’s little cost to implementing these, and little conceptual overhead to users of the language.

Syntax

The grammar would be as follows:

integer-literal:
  ...
binary-integer-literal

binary-integer-literal:
0bbinary-digitsinteger-type-suffixopt
0Bbinary-digitsinteger-type-suffixopt

binary-digits:
binary-digit
binary-digitsbinary-digit

binary-digit:   one of
0 1

svick, giggio, Jexah, glenebob, wieslawsoltes and 28 more


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4