See other answers that adress your direct question. Here's how you can solve your actual problem if you want to do it yourself. There's probably a library that already does that out there, but there's a chance it uses same approach as described below.
Quoting the very wikipedia page you linked to:
Any computer programming language or software package that is used to compute D mod 97 directly must have the ability to handle integers of more than 30 digits. In practice, this can only be done by software that either supports arbitrary-precision arithmetic or that can handle 220 bit (unsigned) integers, features that are often not standard. If the application software in use does not provide the ability to handle integers of this size, the modulo operation can be performed in a piece-wise manner (as is the case with the UN CEFACT TBG5 Javascript program).
Let's see how you could implement this approach with an example:
D = 3214282912345698765432161182
Let's split this number to four parts:
P1 = 321428291 // first 9 digits
P2 = 2345698 // next 7 digits
P3 = 7654321 // next 7 digits
P4 = 61182 // last 5 digits
Then, according to wikipedia, D % 97 == 1
, if following steps lead you to N % 97 == 1
:
Construct N from the first 9 digits of D (P1)
N = 321428291
Calculate N mod 97 = 70
Construct a new 9-digit N from the above result (step 2) followed by the next 7 digits of D (P2).
N = 702345698
- Calculate N mod 97 = 29
Construct a new 9-digit N from the above result (step 4) followed by the next 7 digits of D(P3).
N = 297654321
- Calculate N mod 97 = 24
Construct a new N from the above result (step 6) followed by the remaining 5 digits of D (P4)
N = 2461182
- Calculate N mod 97 = 1
From step 8, the final result is D mod 97 = 1 and the IBAN has passed
this check digit test.
Here's an easy ES6 implementation of similar approach provided by dfsq:
function checkIBAN(iban) {
const parts = iban.match(/.{1,6}/g);
return parts.reduce((prev, curr) => Number(prev + curr) % 97, '');
}
console.log(checkIBAN("3214282912345698765432161182"));