当您需要存储(非常)大的数字时该怎么办?
I am trying to do a Project Euler problem but it involves adding the digits of a very large number. (100!)
Using Java int and long are too small.
Thanks for any suggestions
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
类 BigInteger
看起来这可能就是您正在寻找的。
Class BigInteger
looks like it might be what you are looking for.
使用 BigInteger。 这是示例,来自《Java Examples》一书简而言之,涉及计算阶乘和缓存。
Use BigInteger. Here is an example from the book Java Examples in a Nutshell that involves computing factorials, with caching.
java.lang.BigInteger 或 java.lang.BigDecimal
java.lang.BigInteger or java.lang.BigDecimal