Page 1 of 1

Large decimal numbers

Posted: Tue May 07, 2013 12:10 am
by gradosic
Hi guys,

does anyone knows how to work with large numbers (23 dec) ?
for example, we need to do next action

A=24840081102824244172700
B=97
X=A/B
Result = X - INT(X)

Problem is that xbase only use 18 decimals, no 23.... :-)

Re: Large decimal numbers

Posted: Tue May 07, 2013 1:58 am
by Tom
No way, the limit is exceeded.

But it seems you're trying to calculate the "IBAN" - International Bank Account Number. You may look at my solution for this, to be found in the German Xbase Forum:

http://www.xbaseforum.de/viewtopic.php?f=6&t=6863

(2nd message)

Re: Large decimal numbers

Posted: Tue May 07, 2013 2:09 am
by gradosic
Yes, you are right... I need to calculate IBAN check number...
I look at this forum, but ... "ich nix verstehen" :-) german language.... do you have on this on some other place?

Re: Large decimal numbers

Posted: Tue May 07, 2013 2:26 am
by Tom
Just take the code (three functions) and ignore or delete the comments. You may call the function

Code: Select all

FUNCTION CalcIban(cCiBlz,cCiKonto,cCiIban,cCiLaenderCode)
with at least two parameters, the account number and the old numeric bank id ("Bankleitzahl" in germany). If done so, the country code defaults to "DE" (you may change this in line 3 of the function), if you want to submit a country code, fill the 3rd parameter with Space(22) or an existing IBAN to validate. The function shows how to fragment the large number and calculate the number stepwise. The function "NurZiffern" extracts all the digits from a string ("JustDigits").

Re: Large decimal numbers

Posted: Tue May 07, 2013 2:30 am
by gradosic
Thanks, I will try this!

Re: Large decimal numbers

Posted: Tue May 07, 2013 2:39 am
by gradosic
TOM, IT'S WORKING !!!!!

I just put start konto to 7 decimal (in germany is 8) and I get right IBAN back !!


thank you !!!!!!!!!!!!!

Re: Large decimal numbers

Posted: Tue May 07, 2013 2:42 am
by Tom
Great! :)

You may take a look at the string padding. Account numbers are filled with trailing zeros in this version - but leading zeros may be correct (change PadR() to PadL()).

Re: Large decimal numbers

Posted: Wed May 08, 2013 8:54 am
by unixkd
Hi all

You can use the TORCH browser to translate any website from most popular language to another. Worked very well. Because of this unique capability it is my default internet browser.

Joe

Re: Large decimal numbers

Posted: Wed May 08, 2013 9:12 am
by Tom
Google Translate does the same job. Be careful if source code is translated. ;)

Re: Large decimal numbers

Posted: Thu Aug 29, 2013 12:55 pm
by jdsoft
This is how to calculate Mod(97) of any number of digits.

Code: Select all

   //
   // cNumber = "22152829123456987654322612"
   //
   // Check if cNumber with Mod 10,97 (ISO/IEC 7064:2003) model
   //
   For ni := 1 To Len(cNumber)
      nValue            := Asc(cNumber[ni])-48
      nRet              := ((nRet * 10 ) + nValue) % 97
   Next ni
   //
   // The checksum is part of the calculation (last 2 digits)
   // Calculate last 2 digits that result in Mod 97 = 1
   //
   nRet                 := nRet * 100
   nRet                 := nRet % 97
   nRet                 := 97 - nRet + 1
Jack Duijf