[swift-evolution] BigDecimal functionalities or modulus support for NSDecimalNumber

Charlie Monroe charlie at charliemonroe.net
Sun Jun 26 23:50:56 CDT 2016


It shouldn't be hard to add your own modulo implementation:

mod = code - (floor(code / 97) * 97)

given all operations are on NSDecimalNumber (or Decimal in Swift 3.0)...

> On Jun 25, 2016, at 9:06 PM, Andrea Leganza via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Hello all,
> 
> i was working with huge int numbers (28 digits) due to the developing of an algorithm to check the validity of IBAN bank codes (source: https://en.wikipedia.org/wiki/International_Bank_Account_Number <https://en.wikipedia.org/wiki/International_Bank_Account_Number>)
> 
> The algorithm requests to check the modulus of the 28 digits number with value 97, the only type which was useful due to the size which can contain was NSDecimalNumber (https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDecimalNumber_Class/ <https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDecimalNumber_Class/>) which doesn’t support modulus
> 
> I had to use and external library like this one: https://github.com/mkrd/Swift-Big-Integer <https://github.com/mkrd/Swift-Big-Integer> which supports int and double, maybe adding the modulus operation to NSDecimalNumber will be useful for some users or creating a framework to manage huge int or double.
> 
> if something already exists sorry for the trouble.
> 
> best regards. 
> eng. Andrea Leganza
> —————————————————
> Docente di Fondamenti di programmazione c/o Istituto Quasar - Roma
> Docente di Progettazione di Applicazioni per Dispositivi Mobili c/o Istituto Quasar - Roma
> Docente di Unity3D c/o Vigamus Academy - Roma
> Docente di Programmazione Web c/o ENAIP - Roma
> Redattore magazine Io Programmo - ed. Master
> Adobe Flex & Air certified
> Sun Java 1.6 Certified
> EUCIP Core Certified
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160627/96f5b0e5/attachment.html>


More information about the swift-evolution mailing list