Are double constants truncated for display in VS?

The constant Math.Pi corresponds to a reflector and an MSDN of 3.14159265358979323846. When viewing the Math class in Visual Studio 2010, the value is displayed as 3.14159. Who can I blame for shortening precious constants?

+7
visual-studio metadata
source share
4 answers

I do not know why the OP does not publish this, as this will greatly clarify the situation, but you can reproduce the following:

  • Open IDE
  • Enter Math.PI in the .cs file.
  • Right-click Math.PI and select Go To Definition

This opens the metadata file for Math, which contains the following:

  // // Summary: // Represents the ratio of the circumference of a circle to its diameter, specified // by the constant, π. public const double PI = 3.14159; 
+6
source share

Sorry, I repeat, but how do you get this number? If I hover over a constant or print it in the Immediate or Watch window in VS2010, I get 3.1415926535897931, which is also the value that I get when viewing mscorlib in Reflector.

Although less accurate than the MSDN claims, it is still much better than the number you are talking about. VS must choose the format for printing floating point numbers. With the results that I see, I find it acceptable by default.

+2
source share

You can blame the submission of VS metadata for what you get when you press F12 for something you don't have a source for.

At least I assume that you do, because this is the only place where I can find the shortened constant that you are talking about.

Why is he doing this / where does he get this value from? Who knows...

+2
source share

Perhaps you have a plugin for VS 2010 that changes the number output. Or maybe you are showing the number in the display context, which should truncate the number so that it matches. Where exactly in Visual Studio are you viewing this number?

+1
source share

All Articles