Calculation formula for the general check digit

Asked

Viewed 2,293 times

1

I need to calculate the general checker digit corresponds to the 5th position of the barcode, have the following data.

inserir a descrição da imagem aqui

The check digit will be the result of the subtraction: 11 - rest of the division. If the subtraction result is 0 (zero), 1 (one) or greater than 9 (nine), the check digit shall be 1 (one).

inserir a descrição da imagem aqui

  • 1

    You have already entered the steps to verify the digit. What is your question?

  • What is the doubt? You have everything you need.

  • @Jéfersontavares André Ribeiro the expected DV would be 1 and not the number 5.

  • Dude, show me the code you already have.

  • @Jéfersontas the error is not in the code works blz, it assigns the weight, makes the sum, and finds the rest of the division. The problem is in the assembly itself. I am using this manual https://www.sicredi.com.br/html/para-sua-empresa/received/cobranca/arquivos/25420_manual_beneficiario_cobranca_cnab_400.pdf

  • If you are not getting the right result, the error is in the code. @Fabríciosimonealanamendes

  • @Fabríciosimonealanamendes In the assembly of what? Without seeing your code no one will be able to help you.

  • @You don’t fit the code here

  • Anyway, try to be more specific in your question. The way you are nobody will be able to help.

  • My problem is in calculating the Barcode Checker Digit. On the first line I have the code data, on the second line I have the weight, on the third line I have the remaining multiplication... I don’t know if I can be more explicit than that.

  • Your code may be too much for a comment but you can edit your question and include it there.

  • @OK Jéfersontavares is there in the code

  • Someone has the form to calculate the barcode code DV of the Sicredi billet

Show 8 more comments

1 answer

1

If you as I have come this far. Here’s how I solved my problem.
The general checker digit corresponds to the 5th position of the barcode. The digit 0 (zero) in the 5th position will indicate that the barcode has no checker digit; assign the corresponding weights (from 2 to 9) for each of the 43 digits (except the DV itself) of the Barcode, starting from right to left;  Multiply each digit by its corresponding weight. the first digit from right to left by 2, the second by 3, and so on until it reaches weight 9, when it starts again with weight 2; Accumulate the result of each multiplication; Divide the sum result by 11 (eleven); identify the rest of the division; My problem lies precisely in this last line of algorithm:

     //Agora que tenho a soma vamos pegar o resto da divisão por 11
        mod = 11-(soma % 11);
        //Se o resultado da subtração for 0 (zero), 1 (um) ou maior que 9 (nove), o dígito verificador será 1 (um). Senão o DV é o próprio resultado da subtração.
        if (mod == 0 || mod == 1 || mod > 9)
        {
            dv = 1;
        }
        DvGeral = dv;

 The check digit will be the result of the subtraction: 11 - rest of the division. If the result of the subtraction is 0 (zero), 1 (one) or greater than 9 (nine), the check digit shall be 1 (one). Otherwise the DV is the result of subtraction itself. But helping someone was worth it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.