c++debuggingvisual-studio-2012natvis

Can I control the number of digits displayed in debugger windows for float and double variables?


In Visual Studio 2012, I'm looking for a way to customize the default display of floating point types in the Autos, Locals, and Watch windows. I'm familiar with the Native Visualizer (Natvis) utility, but don't see any debugger formatting facilities to accomplish this. Likewise, I'm not aware of any means to override the default display of any primitive types (aside from enabling hex).

The goal would be to create display strings with fewer digits expanded for types corresponding to points, geometric vectors, etc, but still have all the precision show up when I expand the types. So for example I might have a variable of a point type display as (0.000, 1.234, 2.429) instead of m_x = 0.00000000, m_y = 1.234245213... in the middle column of the Autos window.

I looked through the format specifiers at this page, but don't see a way to control floating point precision.


Solution

  • Unfortunately there is really no way to do this fine grained level of a change in C++ debugging. In a managed language it would be possible in some limited scenarios (when the primitives were fields of objects and annotated with special [DebuggerDisplay] attributes). For C++ though this type of customization just doesn't exist.