当足够高时 Double 无法正确解析

Double not parsing correctly when high enough

我的网站有访问者计数,我试图将其保存为 Double 而不是 Integer,因为它允许更高的数字。

问题是,当计数太高时,例如 300,000,000,000,000,000,000,000,它会被保存为 3.0E+23

我怎样才能将此数字解析为长而规则的格式? 我用 double.TryParse 方法尝试了一些东西,但它没有用。

不,这是不可能的,因为查看 documentation double only stores 15 to 16 digits so it will revert to the short format if the number is larger than that. On the other hand ulong is 64 bits and contain a much larger number accurately, and if that is not enough, there is the BigInteger class,但是你不能将它保存在数据库中,因为它不受支持(BigInt 映射到 long)。