Depends on what you want to achieve.
If it's really used for math, then yes, it's great to have such a library available.
Not many "real" use cases, though, imo, to warrant putting it into the core library atm.
For finance, I guess that's what's `NSDecimalNumber` is for.
This class is not that nice to use from Swift, though.
For crypto, you don't want to use a common BigInt library.
- The library doesn't provide any security guarantees. e.g. when buffers are cleared etc.
- Crypto typically involves fixed sizes (e.g. 256-bit). With common BigInts, you lose performance.
- Crypto is not possible to be implemented securely in pure Swift 2.
The language lacks annotations to prevent compiler optimisations on a fine-grained level.
i.e. timing invariance of comparisons etc is not guaranteed / no control about caching behaviour.
Need to do that in Assembly to be safe against side channel attacks.
Even with Assembly, you may lose to CPU microcode optimisations. Out of scope, though.
On 12 Dec 2015, at 12:37, Otto van Verseveld via swift-evolution <email@example.com> 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).
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!
Thanks in advance, kind regards,
Otto van Verseveld
swift-evolution mailing list