[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pnet-developers] Formatting of System.Decimal
From: |
Rhys Weatherley |
Subject: |
Re: [Pnet-developers] Formatting of System.Decimal |
Date: |
Fri, 18 Mar 2005 11:58:45 +1000 |
User-agent: |
KMail/1.4.3 |
On Thursday 17 March 2005 07:57 pm, Marcus wrote:
> Between version 1.0 and 1.1, MS changed its behavior to conform to the ECMA
> more closely. The spec requires that Decimals preserve trailing zeros
> across most operations. On the other hand, the trailing zeros are not
> significant for equality comparisons, so 12.246 and 12.246000 should
> compare equal. However, the code fragment
>
> Decimal value = 12.246000m;
> Console.WriteLine(value.ToString());
>
> should print 12.246000 (preserving the trailing zeros).
The current pnet code normalizes the decimal point position after every
operation (pnet/support/decimal.c). I suppose it would be possible to modify
the normalization operation to preserve trailing zeros if the result will
still fit in the 96-bit mantissa.
Then some modifications may be needed to the formatting code in pnetlib to use
the exponent to position the decimal point correctly.
> I believe that Pnet has two problems: First, cscc is discarding trailing
> zeros in Decimal constants.
This is due to the normalization that occurs in ILDecimalParse, which would be
fixed if decimal.c is modified as described above.
Cheers,
Rhys.