Re: Decimal Data Type bit layout

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



mdavidjohnson <mdj@xxxxxxxxxxxxx> wrote:
> What is the actual bit layout of the decimal data type?
>
> i.e.; if the double data type layout is sign = 1 bit, biased exponent = 11
> bits, and mantissa = 52 bits; what is the corresponding description for
> decimal?
>
> I read that a decimal includes a 1-bit sign, a 96-bit integer number, and an
> exponent that ranges from 0 to 28 (which would require 5 bits). The total
> would thus be 102 bits which would fit in 13 bytes with two bits left over.
> Seems strange.

That's exactly the layout - if you look at the docs for Decimal, it's
documented there.

I suspect the reason it doesn't go any further is that it's a lot
easier (and quicker) to manipulate three ints as the mantissa than
"three and a bit" ints. I suspect there aren't many applications for
which 28 digits is insufficient, but a couple more digits would be
okay.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: Decimal Data Type bit layout
    ... Sorry, I meant 11-bit exponent (I've got floats, doubles, and decimals all ... > I suspect the reason it doesn't go any further is that it's a lot ... > "three and a bit" ints. ... > which 28 digits is insufficient, but a couple more digits would be ...
    (microsoft.public.dotnet.framework.clr)
  • Re: 5-byte numbers
    ... to all newer OS/2 ones, ... I don't know for 100% sure what the mantissa is. ... also introduces an additional rounding problem. ... assuming 15 digits are readable with an "E" in there. ...
    (comp.os.os2.programmer.misc)
  • Re: BigNum -- Floating Point
    ... > mantissa and exponent. ... In that the current implementation already uses 32-bit "digits", ... (in one design I'm considering) ...
    (comp.programming)
  • Re: Complete RPL object type table
    ... Although HP allocated 20 bits for the DIGITS setting, ... The "LongFloat" library ... ddddddd....ddddddddd - mantissa digits ... - length of exponent and its sign + 5 ...
    (comp.sys.hp48)
  • Re: How to output FLOAT(18) in full form by E-format in VA PL/I?
    ... s=18 (all mantissa's digits). ... File input contains ... I don't worry about 4 digit mantissa in IEEE. ... why I can't use Edescriptor? ...
    (comp.lang.pl1)