function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bretondevbretondev 

System.TypeException: Invalid long: 200410100505000132202606152714

I need to convert a String of this length to any type of number.

But Long is not powerful enough to contain that.

What can I do?
Om PrakashOm Prakash
I suggest to use Decimal
String StrValue = '200410100505000132202606152714';
Decimal decimalValue = Decimal.valueOF(StrValue);
System.debug(decimalValue);
bretondevbretondev
Thanks but I have another problem.
Acually I need to make a modulus with that value, but modulus operation is not available for Decimal.
In fact, I want to write an algorithm to validate an IBAN account.

So if we refere to my example , I need to do 200410100505000132202606152714 mod 97

Mod is not possible with Decimal.
Mod is possible with Long, but Long cannot hold the value.
I'm stuck
Om PrakashOm Prakash
Got it.
​Mod method is not available for decimal so still we couldn't resolve this issue.
 
Nicolas BEVERNAGENicolas BEVERNAGE
Hey,
I have exactly the same issu for IBAN manipulation today. Do you found a solution since march ?
Thanks,
bretondevbretondev
I managed to validate the IBANs in the end.
I have provided solution here :

https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005T30QAE
Matias CalvoMatias Calvo
Hello guys

We have a free application in the Appexchange that does a real IBAN (and others) validation without any Apex code and is updated including the newly supported countries every release.

Check this out: https://goo.gl/HHZ4c3

I hope this helps you and give us feedback to improve it.