How does a .NET decimal
type get represented in binary in memory?
We all know how floating-point numbers are stored and the thusly the reasons for the
https://www.csharpindepth.com/Articles/Decimal
How is a decimal stored?
A decimal is stored in 128 bits, even though only 102 are strictly necessary. It is convenient to consider the decimal as three 32-bit integers representing the mantissa, and then one integer representing the sign and exponent. The top bit of the last integer is the sign bit (in the normal way, with the bit being set (1) for negative numbers) and bits 16-23 (the low bits of the high 16-bit word) contain the exponent. The other bits must all be clear (0). This representation is the one given by
decimal.GetBits(decimal)
which returns an array of 4 ints.