Wednesday, May 26, 2010

C# Decimal type dissected

I was going through C# 4 Essentials. The Decimal type description is sufficient and it is cool to imagine it as +/- N * 10k. But I was not satisfied. The above statement and below url have put me much at ease. Must have been a difficult decision to keep a 128 bit location and leave bits blank after using 102 bits:

Remember machines are binary and 128 is the closest upper 2^x (for a whole number x) above 102.

Update: Even more amazing explanation:
If you are even more interested in the mathematics (non .net specific) check out the below (it will help you understand greg's post as well):
Note: there is something to be found in each of these absent in the rest