Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio debugger - Displaying integer values in Binary

I'm using Visual Studio 2017 and I need to look at the binary representation of integer variables.

How can this be achieved from the Visual Studio debugger?

Visual Studio Watch Window

like image 547
Stepan Ivanenko Avatar asked Dec 20 '17 10:12

Stepan Ivanenko


2 Answers

Type 'var, b' in the watch, for example, enter image description here

like image 87
drerD Avatar answered Sep 23 '22 15:09

drerD


According to the Visual Studio debugger documentation:

You can change the format in which a value is displayed in the Watch, Autos, and Locals windows by using format specifiers.

This note on debugging engine updates and compatibility is also worth noting:

When the Visual Studio native debugger changed to a new debugging engine, some new format specifiers were added and some old ones were removed. The older debugger is still used when you do interop (mixed native and managed) debugging with C++/CLI.

Although it mentions it can be applied to Autos and Locals windows, it is unclear how it is done as the variable names cannot be edited in those windows.

A <variable>, <format> syntax may be used in Watch and Immediate windows, like so:

enter image description here

Here is a direct link to the complete list of format specifiers.

like image 44
rbento Avatar answered Sep 23 '22 15:09

rbento