172

I'm using Visual Studio 2008 and I have just noticed that the debugger is displaying integer values as Hex when I hover over variables and also in the immediate window. I guess I must have hit a shortcut key accidently or something.

Anyone had this before? How do I set it back to display in decimal?

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
fizzer
  • 2,239
  • 3
  • 17
  • 21

7 Answers7

314

Right-click your Watch Window or Immediate Window and uncheck Hexadecimal Display option.

enter image description here

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
  • 4
    wasn't available in Tools Dialog. Only way I could change it back was to add Variable to Watch window and right click in Value field and then I had the Hexadecimal Display check box. – fizzer Jul 28 '10 at 15:40
  • 12
    I was able to do it in the **Call Stack** window in VS2010. – StuperUser Jan 19 '11 at 10:28
  • 2
    Was in the Debugging toolbar for me. – Breandán Feb 04 '11 at 10:43
  • 1
    I think its in the watch window not immediate window. – Soham Dasgupta Dec 02 '11 at 07:39
  • @Soham Dasgupta: if you read the question you see that the user is using Visual Studio 2008 and he mentions the Immediate Window. The answer I provided here is useful in his case as it solves the problem for that specific version of VS. The comments above shows different ways of achieving the same result in Visual Studio 2010. – Leniel Maccaferri Dec 02 '11 at 13:09
  • 2
    Thanks God i got rid of this stupid annoying thing. Thanks @Leniel – Ali Umair Jun 25 '13 at 12:07
  • I'm using VS2013 and can't find where that option is. and sometimes it's hard to follow stackoverflow comments because my tool menus are all Korean.. – Chan Kim Feb 20 '16 at 14:13
  • 3
    Still relevant in 2020 with VS 2019! – Marc Levesque Apr 17 '20 at 15:32
  • Note that there is no indication that it also changes the value of the variable hovers in your code view once you exit the watch window. But this is what you wanted I hope. – tomepenn May 15 '20 at 02:19
50

You can also choose hexadecimal or decimal display on a per-variable basis in the Visual Studio watch window by appending a debugger format specifier to the variable name. In the watch window, enter:

myInt,h
myInt,d

The other very useful format specifiers are ac (see footnote) for 'always calculate', and nq for displaying with 'no quotes.' They can be used together:

my_string_func(),ac,nq

nq is useful inside DebuggerDisplay attributes, which can appear on a class:

[DebuggerDisplay("{my_string_func(),nq}")]
class MyClass
{
    /* ...example continues below... */

...or on one or more field(s) inside a class:

    [DebuggerDisplay("{some_field,nq}", Name="substitute name here")]
    int an_integer;

    [DebuggerBrowsable(DebuggerBrowsableState.Never)]
    String some_field;
}

http://msdn.microsoft.com/en-us/library/e514eeby(v=VS.100).aspx

  • note that earlier versions of the MSDN doc page incorrectly said 'Ac' (with a capital 'A')--which doesn't work
Glenn Slayden
  • 17,543
  • 3
  • 114
  • 108
  • +1, but although MSDN states that `h` is the correct modifier for hex display, it seems (at least in my version, VS 2012 Premium) that `x` works instead (e.g. `1024,x` instead of `1024,h`). Placing `h` returns the "CXX0026 bad format string" error. – vgru Jun 09 '15 at 09:26
  • I suspect that might depend on the language that the module that's being debugged was written in. It's certainly true that debugger expression syntax changes according to the current language. From your message, it appears that you were using C++; I answered as if for C#, although perhaps I shouldn't have assumed that since the OP didn't specify. – Glenn Slayden Jan 06 '17 at 02:17
  • 1
    This provides better discretional control on formatting vs the all or nothing of "Hexadecimal Display" – Fernando Gonzalez Sanchez Oct 31 '17 at 18:10
22

There is a Hex button shown when Visual Studio is run in Debug mode to enable/disable the Hex display

Visual Studio Debug Mode - hex button

DJ'
  • 529
  • 5
  • 6
14

Right-click on client space of almost every debug window (except Immediate Window) - watch/locals/autos/threads/call stack - and uncheck "Hexadecimal Display" option. There's also a "Hex" button in debug toolbar (right to "Step Over" by default) when debugging.

marchewek
  • 541
  • 6
  • 11
9

In Visual Studio 2010 I also saw it in the Debug toolbar, it was highlighted in yellow 'Hex', I just clicked it and it returned to (normal) decimal values

wonea
  • 4,783
  • 17
  • 86
  • 139
Joe
  • 91
  • 1
  • 1
7

Visual Studio 2017 Decimal vs. hexadecimal display is controlled only from the Watch dialog.

  1. Break after setting the variable.
  2. Right mouse click the variable and select "Add Watch" or "QuickWatch"
  3. Right mouse click the line in the Watch dialogue.
  4. Uncheck "Hexadecimal Display"

The display will now be in decimal.

enter image description here

John Pittaway
  • 919
  • 9
  • 9
3

In the immediate window you can uncheck the Hexadecimal Display option.