Hi everyone! Our team will collect data for financial aid for IDPs in Ukraine. I try to create a field for IBAN. We need to set validation for IBAN to exclude mistakes. But it needs big numbers calculations. For example, this is the algorithm for IBAN validation according to the ISO 7064 standard:
MOD (3996220004149005233566882301093; 97) =
3996220004149005233566882301093 – 97 ∗ INT (3996220004149005233566882301093 / 97)
= 1
But when I convert it to Kobo’s formula, it doesn’t work correctly because it needs to calculate too big numbers:
${n} - 97 * int(${n} div 97)
In Google Sheets I resolve big number calculation problem with scripts. Help me please fix it in Kobo!
Yes, the underlying problem is that you are ostensibly limited to 32-bit integers (aka long int) in math operations by the underlying XPath expression engine (and why the docs say “the integer widget has a limit of nine digits…”).
Unfortunately there is no immediate workaround for performing, say, 64-bit integer (aka long long int) math expressions. However, because you are ultimately trying to do modulus arithmetic, and you are dealing with a fixed number of digits in an IBAN number, it may be possible that you can implement a modulus algorithm that keeps all its calculations within long ints.
Note, these algorithms will typically involved iterating over all the base 10 digits in your large integer with a loop, which you cant do in XPath. But because you have a fixed number of digits you can always unroll the loop for however many iterations are required. It’ll be messy, but if you are desperate…
Please do! It’s an interesting problem, and being able to perform data validation in the field is really important. I’ll be very curious to see a working solution to it.