Large decimal numbers

This forum is for general support of Xbase++
Post Reply
Message
Author
gradosic
Posts: 45
Joined: Tue Dec 07, 2010 2:11 pm
Location: Croatia - Europe
Contact:

Large decimal numbers

#1 Post 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.... :-)
Goran Radosic

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Large decimal numbers

#2 Post 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)
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

gradosic
Posts: 45
Joined: Tue Dec 07, 2010 2:11 pm
Location: Croatia - Europe
Contact:

Re: Large decimal numbers

#3 Post 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?
Goran Radosic

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Large decimal numbers

#4 Post 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").
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

gradosic
Posts: 45
Joined: Tue Dec 07, 2010 2:11 pm
Location: Croatia - Europe
Contact:

Re: Large decimal numbers

#5 Post by gradosic »

Thanks, I will try this!
Goran Radosic

gradosic
Posts: 45
Joined: Tue Dec 07, 2010 2:11 pm
Location: Croatia - Europe
Contact:

Re: Large decimal numbers

#6 Post 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 !!!!!!!!!!!!!
Goran Radosic

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Large decimal numbers

#7 Post 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()).
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: Large decimal numbers

#8 Post 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

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Large decimal numbers

#9 Post by Tom »

Google Translate does the same job. Be careful if source code is translated. ;)
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
jdsoft
Posts: 113
Joined: Thu Jan 28, 2010 1:13 pm
Location: Overberg
Contact:

Re: Large decimal numbers

#10 Post 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
Regards,
Jack Duijf

Post Reply