BigDecimal functionalities or modulus support for NSDecimalNumber

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\)

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 (Apple Developer Documentation) which doesn’t support modulus

I had to use and external library like this one: GitHub - mkrd/Swift-BigInt: A lightweight, Multiple Precision Arithmetic Library for Swift! 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

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@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\)

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 (NSDecimalNumber | Apple Developer Documentation) which doesn’t support modulus

I had to use and external library like this one: GitHub - mkrd/Swift-BigInt: A lightweight, Arbitrary Precision Arithmetic Library for Swift! 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@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution