I'm developing a module for generating IBAN codes from current bankaccount. Part of this IBAN code is a Checksum of 2 digits calculated from a large integer. The integer is parsed from a concatenated string. Example of string: '101123100486115909101100' Parsing the string to an integer/long variable using parseInteger() returns an error Parsing the string to an integer/long variable using round(parseFloat()) returns a wrong value What am I doing wrong? Ad2) returns: value 9223372036854775807 Ad1) returns error: Failed to evaluate expression, error occurred on line 1, character 1 parseInteger($varCheckString) ^ at IBANBIC.Calculate_IBANCode (CreateVariable : 'Create CheckSum') Advanced stacktrace: at jJ.a(SourceFile:20) Caused by: java.lang.NumberFormatException: For input string: "101123100486115909101100" at jB.b(SourceFile:38) Caused by: For input string: "101123100486115909101100" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Long.parseLong(Long.java:422) at java.lang.Long.parseLong(Long.java:468) at jD.b(SourceFile:399) at jD.a(SourceFile:101) at jB.b(SourceFile:30) at jJ.a(SourceFile:16) at lU.a(SourceFile:45) at mt.a(SourceFile:77) at ms.a(SourceFile:151) at ms.executeAction(SourceFile:98) at com.mendix.systemwideinterfaces.core.UserAction.execute(SourceFile:57) at com.mendix.core.actionmanagement.CoreAction.call(SourceFile:457) at hC.b(SourceFile:207) at com.mendix.core.Core.execute(SourceFile:226) at ij.getValue(SourceFile:200) at ij.parseValueToString(SourceFile:269) at jl.a(SourceFile:322) at jl.a(SourceFile:276) at jl.a(SourceFile:255) at jl.a(SourceFile:220) at jl.a(SourceFile:205) at jl.a(SourceFile:143) at jl.a(SourceFile:84) at jf.a(SourceFile:48) at jd.a(SourceFile:321) at com.mendix.externalinterface.connector.RequestDispatching$Worker.a(SourceFile:170) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.a(SourceFile:161) at com.mendix.externalinterface.connector.RequestDispatching$Worker$a.apply(SourceFile:160) at akka.actor.Actor$class.apply(Actor.scala:545) at com.mendix.externalinterface.connector.RequestDispatching$Worker.apply(SourceFile:156) at akka.actor.LocalActorRef.invoke(ActorRef.scala:910) at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:25) at akka.dispatch.ExecutableMailbox$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:223) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:123) at akka.dispatch.ExecutableMailbox$class.run(ExecutorBasedEventDrivenDispatcher.scala:195) at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.run(ExecutorBasedEventDrivenDispatcher.scala:123) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:192)
Work around for the checksum in languages that do not support integers with more than 30 chars:
Piece-wise calculation D mod 97:
Starting from the leftmost digit of D, construct a number using the first 9 digits and call it N.
Calculate N mod 97.
Construct a new 9-digit N from the above result (step 2) followed by the next 7 digits of D. If there are fewer than 7 digits remaining in D but at least one, then construct a new N, which will have less than 9 digits, from the above result (step 2) followed by the remaining digits of D.
Repeat steps 2–3 until all the digits of D have been processed.
The result of the final calculation in step 2 will be D mod 97 = N mod 97.
Erwin 't Hoen
The problem here lies in the fact that mendix uses longs but does not allow you to parse it. What you can do is create a java action that parses the string to a long value and then finish your calculation.
Pieter van de Braak
Do the checksum on a string level, parseInteger(substring , pos, 1)
Edit: There seems to be some java implementations available on internet like this
Chris de Gelder
Rene - I think the number is too large for an int variable - max length for int is 2 to the 63rd power minus 1. I suspect float has a similar limitation. Mike
I had same problem and used java class designed for handling big numbers: BigInteger here you can execute mod 97