[swift-evolution] Is there a need for a BigNumber library in Objective-C/Swift?

Dave Abrahams dabrahams at apple.com
Mon Dec 14 20:56:42 CST 2015

> On Dec 12, 2015, at 3:37 AM, Otto van Verseveld via swift-evolution <swift-evolution at swift.org> wrote:
> About I year ago I started, while Swift was still in beta development, a github project containing a wrapper for the GNU Multiple Precision Arithmetic library (see: https://github.com/githotto/osxgmp <https://github.com/githotto/osxgmp>).
> I haven't done much on it lately, also because some questions were not answered in the GMP-community yet. I want to make it also suitable for iOS development, since currently it compiles / runs only on OSX.
> Do you think there is a need for this 'swift-extension' API/library and it is worthwhile developing further such that the Swift language will have a BigDecimal/BigInt library as being present in Java/C#?
> Any thoughts or even help or suggestions on how to get it compiled for iOS are very welcome!

Related:  I have been working for some time on a rewrite of all the integer types and protocols <https://github.com/apple/swift/blob/master/test/Prototypes/Integers.swift.gyb>.  One goal of this effort is to enable operations on mixed integer types, which as you can see is partially completed.  In-place arithmetic (anInt32 += aUInt64) is next.  Another important goal is to make the integer protocols actually useful for writing generic code, instead of what they are today: implementation artifacts used only for code sharing.  As another litmus test of the usefulness of the resulting protocols, the plan is to implement BigInt in terms of the generic operations defined on integers, and make BigInt itself conform to those protocols.

Using GMP would probably result in faster code, and after the protocols have proven themselves adequate for mixed-width/arbitrary-precision integer integer implementation, it might make sense to put a version of the same APIs based on GMP into the standard library.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151214/3c8b27b2/attachment.html>

More information about the swift-evolution mailing list