Why does a C# System.Decimal remember trailing zeros?

后端 未结 3 1653
小鲜肉
小鲜肉 2020-12-06 04:55

Is there a reason that a C# System.Decimal remembers the number of trailing zeros it was entered with? See the following example:

public void DoSomething()
{         


        
3条回答
  •  無奈伤痛
    2020-12-06 05:43

    I think it was done to provide a better internal representation for numeric values retrieved from databases. Dbase engines have a long history of storing numbers in a decimal format (avoiding rounding errors) with an explicit specification for the number of digits in the value.

    Compare the SQL Server decimal and numeric column types for example.

提交回复
热议问题