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

后端 未结 6 1974
别跟我提以往
别跟我提以往 2021-01-08 00:51

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

6条回答
  •  情书的邮戳
    2021-01-08 01:51

    Based on Overlord Zurg's answer, display the value of m_x with three digits as follows:

    
      
        {(int)m_x}.{(int)(10*m_x) % 10}{(int)(100*m_x) % 10}{(int)(1000*m_x) % 10}
      
    
    

    To account for negative numbers as well:

    
      
        {(int)m_x}.{(int)((m_x<0?-1:1)*10*m_x) % 10}{(int)((m_x<0?-1:1)*100*m_x) % 10}{(int)((m_x<0?-1:1)*1000*m_x) % 10}
      
    
    

提交回复
热议问题