大数值转换问题

发布于 2024-09-12 04:58:53 字数 130 浏览 4 评论 0原文

我有一个很大的文本字符串数字(20 个字符,无小数)需要转换为数字。我尝试了 Convert.ToInt64 但该值太大。对于这么大的数字,最好的转换方法是什么?并且,Convert.ToInt64() 的实际最大值是多少?

谢谢

I have a large text string number (20 characters, no decimals) that needs to be converted to a number. I tried Convert.ToInt64 but the value is too large. What is the best conversion method for a number this large? And, what is the actual max value for Convert.ToInt64()?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞笑我太脆弱 2024-09-19 04:58:53

Int64 支持从 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807 的数字。

您可以使用UInt64(到18,446,744,073,709,551,615)更大。

如果您需要更大的值,最好的选择是使用 BigInteger ,使用 BigInteger.TryParse 而不是 Convert.ToXXX。 BigInteger 支持任意大的整数值,因此大小可以根据需要很大。

Int64 supports numbers from -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807.

You can go larger using UInt64 (to 18,446,744,073,709,551,615).

If you need bigger than that, the best option is to use BigInteger, with BigInteger.TryParse instead of Convert.ToXXX. BigInteger supports arbitrarily large integer values, so the size can be as large as needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文