I suggest you ...

Implement support for binary, octal and hex literals

I know VB supports hex literals but these need to be improved so instead of using the &h prefix, you could use a suffix:
Dim hexValue = 1F7h

The same way you could then implement both binary and octal literals:
Dim binValue = 01100011b
Dim octValue = 722o

28 votes
Sign in
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    XavierXavier shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →
    completed  ·  Visual Studio teamAdminVisual Studio team (Product Team, Microsoft) responded  · 

    Hey everyone,

    If you hadn’t heard already last week at BUILD we announced the PUBLIC release of a Preview of the next version of the Visual Basic language and code editing experience powered by “Roslyn”. You can download this preview and install it on top of Visual Studio 2013 today!

    I’m excited to let you know that included in this is a preview of a new language feature we’re considering: Binary literals!

    Dim value = &B11010001

    We’ve also included digit group separators in this preview so that you can break up those long binary numbers (and hex, octal, and decimal numbers too):

    Dim value = &B1101_0001

    AND in honor of a special request from Xavier we also support in this preview the space as a separator character (and we’re terrified of it :))

    Dim value = &B 1101 0001

    You can read about it more here: http://www.codeplex.com/Download?ProjectName=roslyn&DownloadId=824695

    Download the End User Preview @ http://msdn.microsoft.com/en-US/vstudio/roslyn

    I encourage you all to download it, try it out, and send us your feedback.


    Anthony D. Green, Program Manager, Visual Basic & C# Languages Team


    Sign in
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      • XavierXavier commented  ·   ·  Flag as inappropriate

        Just installed the Roslyn End User Preview and the fact that you can now use group separators for the literals is just a life saver!
        And they work great with octals and hex numbers too. Brilliant!

        As for me, I vote for the blank space.

        Also, this new feature now allows us to prefix our hex values with zeros:
        Dim value1 = &H 00 00 C0 00

        However, they fail to work in the "immediate window", but I guess that's to be expected.
        Also, it is quite easy to crash VS doing some weird stuff with this new feature. For example, try writing this line of code (notice the lowercase "&h"):
        Dim value1 As UShort = &B 11 01 00 01 * 3 / &h FF 10

      • Dan WalkerDan Walker commented  ·   ·  Flag as inappropriate

        Im in agreement with Xavier. Consistent syntax is always a plus to beginners as well as experienced programmers. However, I would propose that the syntax more closely match that of other languages. Something like:

        Dim value As Int64 = 0xDEADBEEF ' hex
        Dim value As Int32 = 0b1001110101 ' binary

        Or possibly make them first class citizens:

        Dim value As Hex32 = DEAD BEEF
        Dim value As Binary = 10110001101

        The problem with the second choice is where hex uses letters in its symbol set. So the compiler wouldn't be able to tell a hex value from a variable name.

        Perhaps some prefixing is needed..
        Dim value As Hex32 = "DEAD BEEF"
        Dim value As Hex32 = (DEAD BEEF)
        Dim value As Hex32 = [DEAD BEEF]

      • XavierXavier commented  ·   ·  Flag as inappropriate

        These are great news Anthony.

        The grouping feature will definitely be a welcome one... but, please, consider using spaces, otherwise it will look "too noisy".

        As for the syntax change to identify between the different bases, if possible, at least consider it.
        I (personally) find the "&" prefix extremely inconvenient.

        In any case, thank you for considering this "improvement"!

      Feedback and Knowledge Base