Render custom floating point class in debugger

I have already made several attempts in autoexp.dat to make it easier to check the user line and other simple classes in the Visual Studio debugger (using vs2005). I would really like to see directly the value (or approximation) of our custom floating point class. The internal representation is a four-digit integer (int mantissa [4], 128 bits x86), which will be divided by 10 by the power of our indicator. So basically it looks like this:

class FloatingPoint
{
   private:
      char exponent;
      int mantissa[4]
};

The following statement converts it to double, since fp is an object of type FloatingPoint:

(mantissa[0] + 
   * ((double)mantissa[1] * 32 * 2) 
   * ((double)mantissa[2] * 64 * 2) 
   * ((double)mantissa[3] * 96 * 2))
   /  std::pow(10, fp.exponent)

- Visual Studio FloatingPoint ? pow - , ... , ?

+3
2

, ( ) double power10[256];. . : , - 0. Immediate, .

signed char, unsigned char . (, signed, float). char , , .

( ):

FloatingPoint {
  preview (
    #([($c.mantissa[0]  + $c.mantissa[1] * 64.0 + $c.mantissa[2] * 128.0 + $c.mantissa[3] * 192.0) / power10[$c.exponent], f])
  )
  stringview (
    #([($c.mantissa[0]  + $c.mantissa[1] * 64.0 + $c.mantissa[2] * 128.0 + $c.mantissa[3] * 192.0) / power10[$c.exponent], f])
  )
  children([$c,!])
}
+2

, , -

const char* FloatingPoint::ToString () const
{
  static char buf[64];
  double d = (mantissa[0] + 
   * ((double)mantissa[1] * 32 * 2) 
   * ((double)mantissa[2] * 64 * 2) 
   * ((double)mantissa[3] * 96 * 2))
   /  std::pow(10, fp.exponent);
  sprintf(buf, "%f", d);
  return buf;
}

Floatingpoint =<ToString()> [AutoExpand].

+2

Source: https://habr.com/ru/post/1762247/


All Articles