0

I am doing a CRC program in C. Basically I am taking input in binary as a char array as dividend and divisor. Now I want to perform division operation on this two numbers. To perform arithmetic operation I will first convert this number in to integers, for example, '0' + t[1]. Now how do I perform bitwise modulo operation on this bits? Or if anyone know any better way to implement CRC on sender and receiver side, please suggest me?

Ok I think my words are bit confusing. I will try to make understand what I want to do by giving a simple example, suppose the dividend entered is 11100101 and the divisor is 11011, then what should happen is

enter image description here

Observe in the image given that selected numbers are divided they are XORed against the result. Here I want the same thing to happen in my program as is illustrated in the image. How do I perform this kind of bit by bit division?

iammurtaza
  • 957
  • 3
  • 16
  • 31
  • You may be interested by [bignums](http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic) and libraries like https://gmplib.org/ ; also look inside existing C code similar to yours (perhaps code of MD5 or SHA1) – Basile Starynkevitch Mar 11 '14 at 10:13
  • 4
    I'm having trouble understanding your question, please try to clarify. "Modulo" is "remainder after division"; you can't divide a single bit by very much so it doesn't make sense to me to talk about modulo "on each bit". Also your talk about converting "number to integer" by doing what looks like conversion to decimal *digit character* is very confusing. – unwind Mar 11 '14 at 10:16
  • use shifts to left and right to "access individual bits", well actually you simply set the highter bits or the lower bits to 0, since the smallest unit you can access is a byte! – H_squared Mar 11 '14 at 10:20
  • You can look CRC calculation code here http://read.pudn.com/downloads21/sourcecode/embed/70296/File_Sys/FileSys/src/CRC32.c__.htm and http://mail.millennium.berkeley.edu/pipermail/tinyos-help/2003-September/002001.html – Jayesh Bhoi Mar 11 '14 at 10:20
  • Check this link: http://www.barrgroup.com/Embedded-Systems/How-To/CRC-Calculation-C-Code – H_squared Mar 11 '14 at 10:21
  • 1
    Also on SO also you can look http://stackoverflow.com/questions/847450/checksum-calculation – Jayesh Bhoi Mar 11 '14 at 10:22
  • I have edited my question. I hope you can understand it now. Please provide me some guide. I googled a lot but didn't find the exact solution. – iammurtaza Mar 11 '14 at 13:06

0 Answers0