Is there someone who can see what is going on please.
FYI, I use the code for bankaccountnumber validation.
The numbers to be checked have up to 30 digits!
In javascript, all numbers are floating point numbers (See this page for more info). The result of this is that numbers in javascript have a limited number of significant digits (17 according to your findings).
I don’t have a real solution for this now, but your answer is hidden somewhere in the source of the calculator you linked to.
My tests on your numbers show the same (wrong) results in javascript in Servoy.
On my machine running java 1.6 (32 bits):
However note that the largest integer is: 2147483647 (comes from java.lang.Integer.MAX_VALUE )
and the largest long integer is: 9223372036854775807 (comes from java.lang.Long.MAX_VALUE)
So your input number of 111222333444555666 is larger than the largest integer but smaller than the largest long.
However your second number of 370400440532013000131489 is larger than both the largest integer and the largest long.
That is why you get an error - the arithmetic is done wrong due to conversions internally.
I used to java to check out the modulus arithmetic and it seems that using BigInteger would help.
However this seems to be difficult to do in plain javascript. (Because it does not recognize the remainder as a function of BigInteger). Maybe looking for a java script library or plugin to do the work would be useful.
Thanks for your replies guys.
It appears that I can only use bankaccount numbers of 15 digits max.
This means Servoy cannot be used for serious valdidation calculations, like
checking the European IBAN accountnumbers which converted string is always > 16
I understand that Servoy is not realy to blame but Java/Javascript is.
What I don’t understand is how the Javascript calculator does the job.
I checked the results of the calculator against my FMP testsolution and it both gives the same correct results.
In the helpfile of this calculator the author says that he uses a MOD function and not the % operator.
Question is how does this function look like???
I looked at the JS from the calculator site and when you load it up there is a license banner that suggests that you contact the developer if you want to use the code in a commercial solution. Since the code is just JS you could fairly simply use it in Servoy/your solution (assuming that you follow the licensing guidelines and assuming you are using Servoy 4). Why not contact the developer? He/she seems to have the code/knowledge you need.
Maybe you can use this method to double the amount of figures you can use: 111222333444555666 % 20 = (111222333444 * 1000000 + 555666) % 20 = (111222333444 % 20 * 1000000 % 20 + 555666 % 20) % 20 . Of course, read the figures as string and split them. If double the number of figures is not enough a recursive method can be done to calculate the remainder (if number of digits bigger than max value split the string as above calling the function again for each part, else return number % 20 ).