Go Back   Trackpads Community > General Discussions > Computer and Technology > Microsoft Applications

Microsoft Applications Discussions about Windows and other MS Products such as Office

Reply
 
LinkBack Thread Tools
Old 06-03-2005, 08:00   #1 (permalink)
Ritesh Sara
Civilians

 
Default Check Digit calculation (IBAN) - Discrepancies when using numbers with 18 digits or MOD-function

Hi guys,

I am trying to calculate check digits (Modulus 97 check) for an IBAN
creation demo and am running in serious problems with Excel. First approach
I tried is to use the MOD-function however this seems to be not possible
using numbers with 18 digits.

Next approach I tried is a "step by step" calcualtion however the Excel
results are NOT correct when dividing numbers with 18 digits.

E.g. 210005665660111000 / 97 = 2165006862475370.00 -> rcorrect result should
be 2165006862475371.1340

Does anybody have any experience with this discrepancies or with check digit
calculations in Excel.

Thanks much for all your help.


Ritesh


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Trackpads Information
Click to Visit
Old 06-03-2005, 12:00   #2 (permalink)
Niek Otten
Civilians

 
Default Re: Check Digit calculation (IBAN) - Discrepancies when using numbers with 18 digits or MOD-function

Hi Ritesh,

Excel's precision is 15 significant digits.
If you require more digits, make it text. Of course you then can't calculate
with it, but you can retrieve any character with the LEFT(), RIGHT() and
MID() functions.

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Ritesh Sara" <ritesh_sarampan@hotmail.com> wrote in message
news:%23r1%23aaCaFHA.3528@TK2MSFTNGP09.phx.gbl...
> Hi guys,
>
> I am trying to calculate check digits (Modulus 97 check) for an IBAN
> creation demo and am running in serious problems with Excel. First
> approach I tried is to use the MOD-function however this seems to be not
> possible using numbers with 18 digits.
>
> Next approach I tried is a "step by step" calcualtion however the Excel
> results are NOT correct when dividing numbers with 18 digits.
>
> E.g. 210005665660111000 / 97 = 2165006862475370.00 -> rcorrect result
> should be 2165006862475371.1340
>
> Does anybody have any experience with this discrepancies or with check
> digit calculations in Excel.
>
> Thanks much for all your help.
>
>
> Ritesh
>
>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-03-2005, 12:00   #3 (permalink)
Ron Rosenfeld
Civilians

 
Default Re: Check Digit calculation (IBAN) - Discrepancies when using numbers with 18 digits or MOD-function

On Fri, 3 Jun 2005 12:25:40 +0200, "Ritesh Sara" <ritesh_sarampan@hotmail.com>
wrote:

>Hi guys,
>
>I am trying to calculate check digits (Modulus 97 check) for an IBAN
>creation demo and am running in serious problems with Excel. First approach
>I tried is to use the MOD-function however this seems to be not possible
>using numbers with 18 digits.
>
>Next approach I tried is a "step by step" calcualtion however the Excel
>results are NOT correct when dividing numbers with 18 digits.
>
>E.g. 210005665660111000 / 97 = 2165006862475370.00 -> rcorrect result should
>be 2165006862475371.1340
>
>Does anybody have any experience with this discrepancies or with check digit
>calculations in Excel.
>
>Thanks much for all your help.
>
>
>Ritesh
>


Excel's precision is fifteen digits.

You may be able to use VBA and use the Decimal data type depending on the
algorithm.


--ron
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-03-2005, 12:00   #4 (permalink)
Dana DeLouis
Civilians

 
Default Re: Check Digit calculation (IBAN) - Discrepancies when using numbers with 18 digits or MOD-function

I don't see the original post, so here are some general ideas. Hope this
helps.
I used Int since you are doing Mod 97, and it shouldn't make a difference.
A higher Mod requires a few more steps. I mention this as the use of Int( )
will revert back to double.

Sub Demo()
Dim n
Dim R As Long
n = CDec("210005665660111000") / 97
R = (n - Int(n)) * 97

Debug.Print n
Debug.Print R
End Sub

Returns:
2165006862475371.1340206185567
13

Which checks with another program:
Mod[210005665660111000, 97]
13

HTH :>)
--
Dana DeLouis
Win XP & Office 2003


"Niek Otten" <nicolaus@xs4all.nl> wrote in message
news:epCsYHDaFHA.2996@TK2MSFTNGP10.phx.gbl...
> Hi Ritesh,
>
> Excel's precision is 15 significant digits.
> If you require more digits, make it text. Of course you then can't
> calculate with it, but you can retrieve any character with the LEFT(),
> RIGHT() and MID() functions.
>
> --
>
> Kind Regards,
>
> Niek Otten
>
> Microsoft MVP - Excel
>
> "Ritesh Sara" <ritesh_sarampan@hotmail.com> wrote in message
> news:%23r1%23aaCaFHA.3528@TK2MSFTNGP09.phx.gbl...
>> Hi guys,
>>
>> I am trying to calculate check digits (Modulus 97 check) for an IBAN
>> creation demo and am running in serious problems with Excel. First
>> approach I tried is to use the MOD-function however this seems to be not
>> possible using numbers with 18 digits.
>>
>> Next approach I tried is a "step by step" calcualtion however the Excel
>> results are NOT correct when dividing numbers with 18 digits.
>>
>> E.g. 210005665660111000 / 97 = 2165006862475370.00 -> rcorrect result
>> should be 2165006862475371.1340
>>
>> Does anybody have any experience with this discrepancies or with check
>> digit calculations in Excel.
>>
>> Thanks much for all your help.
>>
>>
>> Ritesh
>>
>>

>
>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-03-2005, 12:00   #5 (permalink)
Dave Peterson
Civilians

 
Default Re: Check Digit calculation (IBAN) - Discrepancies when using numberswith 18 digits or MOD-function

If you store that 18 digit value as a string by preformatting the cell as Text
or typing your entry with a leading quote '210005665660111000, you could use a
User Defined Function to do the checksum.

Option Explicit
Function IBANChkSum(rng As Range) As Variant

Dim myVal As Variant

Set rng = rng(1)
If Application.IsNumber(rng.Value) = True Then
IBANChkSum = CVErr(xlErrRef)
Else
If IsNumeric(rng.Value) = False Then
IBANChkSum = CVErr(xlErrRef)
Else
myVal = CDec(rng.Value)
IBANChkSum = "'" & Format(myVal / 97, "0.0000")
End If
End If

End Function

I got this returned: '2165006862475371.1340
(yes, with the leading single quote to force text)

But a small search using Google sure makes it look like this is not sufficient:
http://www.ecbs.org/Download/EBS204_V3.2.pdf

But maybe it's just part of your routine???





Ritesh Sara wrote:
>
> Hi guys,
>
> I am trying to calculate check digits (Modulus 97 check) for an IBAN
> creation demo and am running in serious problems with Excel. First approach
> I tried is to use the MOD-function however this seems to be not possible
> using numbers with 18 digits.
>
> Next approach I tried is a "step by step" calcualtion however the Excel
> results are NOT correct when dividing numbers with 18 digits.
>
> E.g. 210005665660111000 / 97 = 2165006862475370.00 -> rcorrect result should
> be 2165006862475371.1340
>
> Does anybody have any experience with this discrepancies or with check digit
> calculations in Excel.
>
> Thanks much for all your help.
>
> Ritesh


--

Dave Peterson
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-03-2005, 20:00   #6 (permalink)
Harlan Grove
Civilians

 
Default Re: Check Digit calculation (IBAN) - Discrepancies when using numbers with 18 digits or MOD-function

Dana DeLouis wrote...
....
>I used Int since you are doing Mod 97, and it shouldn't make a difference.
>A higher Mod requires a few more steps. I mention this as the use of Int( )
>will revert back to double.
>
>Sub Demo()
> Dim n
> Dim R As Long
> n = CDec("210005665660111000") / 97
> R = (n - Int(n)) * 97
>
> Debug.Print n
> Debug.Print R
>End Sub
>
>Returns:
> 2165006862475371.1340206185567
> 13
>
>Which checks with another program:
>Mod[210005665660111000, 97]
>13

....

Personally, I prefer divide & conquer (pun intended), and for division
the best d&c algorithm is long division. If there are 18 decimal
numberals in the numeric string, the remainder when dividing by 97 is
given by

=MOD(MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&MID(s,1 3,6),97)

Elementary school long division uses one numeral at a time, but it's
not necessary. It's reasonably efficient to use 3 chunks of 6 numerals
each. Note that using 2 chunks of 9 numerals each can bump into the bug
in Excel's MOD function
(http://support.microsoft.com/default...b;en-us;119083).

FTHOI, the quotient is given by

=INT(MID(s,1,6)/97)&TEXT(INT((MOD(MID(s,1,6),97)&MID(s,7,6))/97),"000000")
&TEXT(INT((MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&M ID(s,13,6))/97),"000000")

and the full result could be given by

=INT(MID(s,1,6)/97)&TEXT(INT((MOD(MID(s,1,6),97)&MID(s,7,6))/97),"000000")
&TEXT(INT((MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&M ID(s,13,6))/97),"000000")
&TEXT(MOD(MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&MI D(s,13,6),97)/97,
".000000000000000")

which returns

2165006862475371.134020618556701

Who says Excel can't handle more than 15 decimal digits?!

 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-04-2005, 16:00   #7 (permalink)
Dana DeLouis
Civilians

 
Default Re: Check Digit calculation (IBAN) - Discrepancies when using numbers with 18 digits or MOD-function

Thanks Harlan! Very nice. I've never seen that before. Interesting. :>)
Looks like one can break the number into different size chunks and it still
works.
I was messing around with vba. I'm trying different text ideas for speed.
This is version 1.
I really wish that Mod bug would get fixed.
Anyway, thanks again. :>)

Sub Demo()
Dim n, v, r, j
n = CDec("1234567890123456789012345678")
v = Split(Format(n, "###### ###### ###### ###### ######"), Space(1))

r = v(0) Mod 97
For j = 0 To UBound(v) - 1
r = (r & v(j + 1)) Mod 97
Next j
Debug.Print r
End Sub

returns: 52
which checks with another program:

Mod[1234567890123456789012345678, 97]
52

Thank you very much. :>)
--
Dana DeLouis
Win XP & Office 2003


"Harlan Grove" <hrlngrv@aol.com> wrote in message
news:1117832336.754804.17820@g49g2000cwa.googlegro ups.com...
> Dana DeLouis wrote...
> ...
>>I used Int since you are doing Mod 97, and it shouldn't make a difference.
>>A higher Mod requires a few more steps. I mention this as the use of
>>Int( )
>>will revert back to double.
>>
>>Sub Demo()
>> Dim n
>> Dim R As Long
>> n = CDec("210005665660111000") / 97
>> R = (n - Int(n)) * 97
>>
>> Debug.Print n
>> Debug.Print R
>>End Sub
>>
>>Returns:
>> 2165006862475371.1340206185567
>> 13
>>
>>Which checks with another program:
>>Mod[210005665660111000, 97]
>>13

> ...
>
> Personally, I prefer divide & conquer (pun intended), and for division
> the best d&c algorithm is long division. If there are 18 decimal
> numberals in the numeric string, the remainder when dividing by 97 is
> given by
>
> =MOD(MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&MID(s,1 3,6),97)
>
> Elementary school long division uses one numeral at a time, but it's
> not necessary. It's reasonably efficient to use 3 chunks of 6 numerals
> each. Note that using 2 chunks of 9 numerals each can bump into the bug
> in Excel's MOD function
> (http://support.microsoft.com/default...b;en-us;119083).
>
> FTHOI, the quotient is given by
>
> =INT(MID(s,1,6)/97)&TEXT(INT((MOD(MID(s,1,6),97)&MID(s,7,6))/97),"000000")
> &TEXT(INT((MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&M ID(s,13,6))/97),"000000")
>
> and the full result could be given by
>
> =INT(MID(s,1,6)/97)&TEXT(INT((MOD(MID(s,1,6),97)&MID(s,7,6))/97),"000000")
> &TEXT(INT((MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&M ID(s,13,6))/97),"000000")
> &TEXT(MOD(MOD(MOD(MID(s,1,6),97)&MID(s,7,6),97)&MI D(s,13,6),97)/97,
> ".000000000000000")
>
> which returns
>
> 2165006862475371.134020618556701
>
> Who says Excel can't handle more than 15 decimal digits?!
>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Losing last digit on 16 digit number davee10 Microsoft Applications 1 10-12-2005 10:05
Digits in text cannot format as Numbers ? st24961 Microsoft Applications 3 05-31-2005 04:00
Which function find numbers not same. Cactus [ΟΙΘΛΗς] Microsoft Applications 5 12-24-2004 07:00
What function returns the Nth position in a sequence of numbers? Shiperton Henethe Microsoft Applications 4 11-19-2004 10:00
Check for 3 numbers in Cell before totalling Bradley Microsoft Applications 11 06-17-2004 16:08


Community Information
Options
Quick Options
Trackpads Non-Commercial Ad
Copyright Information Click to Visit
Time
Server Time
All times are GMT -4. The time now is 13:50.
Copyright
Copyright Information
The header is based off of work by Vipixel.com and modified by this site. Trackpads and the Trackpads Logo are both Registered Trademarks of Jason Edwards and cannot be used without prior written permission.  The only exception is as a link back to this site. Trackpads is a private website run by a small legion of volunteers, 3 dogs, 12.5 cats and an army of small, super smart, bio-engineered mice with pointy hats and tutu's. Search Engine Friendly URLs by vBSEO 3.2.0 RC7
Archive Links
Archive Links
Page generated in 0.86363 seconds with 19 queries