Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integer with 24 digits

Tags:

c#

biginteger

To check some bank account numbers I want to do a modulo 97 on an account number. But a lot of account number is to big to enter in a UInt64.

How can I do an opperation on a 24 digits integer ?

Thanks,

Sample code (it can't convert) :

(Convert.ToUInt64("756842356987456214536254") % 97 == 1);
like image 514
Franck Charlier Avatar asked Nov 22 '12 08:11

Franck Charlier


2 Answers

One way would be to use System.Numeric's BigInteger:

BigInteger bi = BigInteger.Parse("756842356987456214536254");
like image 192
Mitch Wheat Avatar answered Oct 14 '22 21:10

Mitch Wheat


Thanks,

It's work.

Org.BouncyCastle.Math.BigInteger bi = new BigInteger("756842356987456214536254");

(Convert.ToInt32(bi.Mod(new BigInteger("97")).ToString()) == 1);
like image 43
Franck Charlier Avatar answered Oct 14 '22 22:10

Franck Charlier