Swift 中的 BigInteger 等价物? [英] BigInteger equivalent in Swift?

查看:49
本文介绍了Swift 中的 BigInteger 等价物?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Swift 中是否有与 Java 的 BigInteger 等价的类?我想在 Swift 中使用大于 UInt64 最大值的正整数进行大型计算.

Is there an equivalent to Java's BigInteger class in Swift? I am tying to do large calculations in Swift with positive integers larger than UInt64 maximum valye.

在 Swift 中处理这些数字的最佳方法是什么?

What is the best way to handle these numbers in Swift?

推荐答案

您可以使用 Cocoa 的 NSDecimalNumber 类.它不是无限精度,但可以表示精度的 38 位十进制数字,这可能足以满足您的需要.

You can use the NSDecimalNumber class from Cocoa. It is not infinite precision, but it can represent 38 decimal digits of precision, which may be enough for what you need.

这篇关于Swift 中的 BigInteger 等价物?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆