Decimal - truncate trailing zeros

后端 未结 3 1633
旧巷少年郎
旧巷少年郎 2020-12-18 19:48

I noticed that .NET has some funky/unintuitive behavior when it comes to decimals and trailing zeros.

0m == 0.000m //true
0.1m == 0.1000m //true
         


        
3条回答
  •  醉话见心
    2020-12-18 20:28

    I think that what you need is this (more details in my answer here) :

    public static decimal Normalize(decimal value)
    {
        return value/1.000000000000000000000000000000000m;
    }
    

提交回复
热议问题