dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] Formatting of System.Decimal


From: Marcus
Subject: [Pnet-developers] Formatting of System.Decimal
Date: Thu, 17 Mar 2005 03:57:29 -0600
User-agent: KMail/1.8

The recent conversions about formatting got me to thinking about a problem in 
Pnet's handling of System.Decimal. The problem seems to be both in the cscc 
compiler and in the bcl output formatting.

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).

I believe that Pnet has two problems: First, cscc is discarding trailing zeros 
in Decimal constants. Referring to the code fragment above, when I compile 
with mcs and run with mono, I get 12.246000. But if I compile with cscc and 
run with mono, I get 12.246. Second, regardless of which compiler I use, 
ilrun prints 12.246.

Reference (scroll down to the topic ``Why did Decmial.ToString'')
http://msdn.microsoft.com/netframework/programming/bcl/faq/NumericTypesFAQ.aspx


reply via email to

[Prev in Thread] Current Thread [Next in Thread]