BigInteger相当于Swift? [英] BigInteger equivalent in Swift?

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

问题描述

在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's maximum number. What is the best way to handle these numbers?

推荐答案

您可以使用 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.

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

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