Industry standard for Check Digit

  • Anybody knows what the industry standard is for calculating check digit using Modulus when it comes to leading 0s in the string.  Is the practice to trim the leading 0s and then apply the algorithm or apply it on the original string?

    Thanks.

  • imo a modulus is jus a math-exercise, so leading zeroes do not matter, but for correctness allways have them leading your string and handle the CD in your input-presentation layer or businessmodel.

    Check this :

    declare @thenumber as char(12)

    declare @cd smallint

    declare @Themod smallint

    select @Themod = 97, @thenumber = '000141822585'

    select @cd = convert(bigint,substring(@thenumber,1,10)) % @Themod

    if @cd = convert(smallint,substring(@thenumber,11,2))

       print 'CD OK'

    else

     Print 'CD not OK'

     

     

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply