Quantcast
Channel: 2,000 Things You Should Know About C# » Visual Studio
Viewing all articles
Browse latest Browse all 21

#1,090 – Using Visual Studio to Verify How Floating Point Numbers Are Stored

$
0
0

Recall that floating point numbers are stored in memory by storing the sign bit, exponent and mantissa.

We showed that the decimal value of 7.25, stored as a 32-bit floating point value, is stored as the binary value 0x40E80000.

1089-001

We can verify this in Visual Studio by assigning a float to contain the value 7.25 and then looking at that value in memory.

1090-001

Notice that the bytes appear to be backwards, relative to their order as written above.  This is because Intel is a little-endian platform (bytes at “little” end of 32-bit word are stored first).


Filed under: Basics Tagged: Basics, C#, Floating Point, Visual Studio

Viewing all articles
Browse latest Browse all 21

Latest Images

Trending Articles





Latest Images