473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

CRC calculation

Hi,

I have found a piece of C code for checksum calculation
CRC16 ccitt.

Is that right?
How can I initialize crc?


#include <stdio.h>

int crc_1021(int data)
{

int x;

x = ((crc>>8) ^ data) & 0xff;
x ^= x>>4;
crc = (crc << 8) ^ (x << 12) ^ (x <<5) ^ x;
crc &= 0xffff;

return(crc);

}

int main()

{
int crc
printf("The CRC16-X25_ccitt of %d is %d. \n", crc, crc_1021(crc));
return 0;
}
Nov 14 '05 #1
5 10556
ALuPin wrote:
I have found a piece of C code for checksum calculation
CRC16 ccitt.

Is that right?
How can I initialize crc?


Errr. Where is your question about the C language?

Nov 14 '05 #2
On 2 Jul 2004 04:23:19 -0700, AL****@web.de (ALuPin) wrote in
comp.lang.c:
Hi,

I have found a piece of C code for checksum calculation
CRC16 ccitt.

Is that right?
How can I initialize crc?


#include <stdio.h>

int crc_1021(int data)
{

int x;

x = ((crc>>8) ^ data) & 0xff;
x ^= x>>4;
crc = (crc << 8) ^ (x << 12) ^ (x <<5) ^ x;
crc &= 0xffff;

return(crc);

}

int main()

{
int crc
Change the line above to:

int crc = /* whatever initial value you want */
printf("The CRC16-X25_ccitt of %d is %d. \n", crc, crc_1021(crc));
return 0;
}


--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #3
Grumble <a@b.c> wrote in message news:<cc**********@news-rocq.inria.fr>...
ALuPin wrote:
I have found a piece of C code for checksum calculation
CRC16 ccitt.

Is that right?
How can I initialize crc?


Errr. Where is your question about the C language?


Hey,

if you do not want to help then SHUT UP.

Thank you very much.

Best regards
Nov 14 '05 #4
"ALuPin" <AL****@web.de> wrote in message
news:b8**************************@posting.google.c om...
Grumble <a@b.c> wrote in message news:<cc**********@news-rocq.inria.fr>...
ALuPin wrote:
I have found a piece of C code for checksum calculation
CRC16 ccitt.

Is that right?
How can I initialize crc?


Errr. Where is your question about the C language?


Hey,

if you do not want to help then SHUT UP.

Thank you very much.

Best regards


You are posting your question in the wrong
group, so please take your own advice.
Nov 14 '05 #5
On 5 Jul 2004 00:07:31 -0700, in comp.lang.c , AL****@web.de (ALuPin)
wrote:
Grumble <a@b.c> wrote in message news:<cc**********@news-rocq.inria.fr>...
Errr. Where is your question about the C language?


if you do not want to help then SHUT UP.


You ask an offtopic question, get asked what your actual relevant question
is, and are rude? Thats very silly.
Thank you very much.


Welcome.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Aspersion | last post by:
I'm building an ASP page that has a lot of text and graphics. There is a calculation facility on the page. The user enters several numbers in a form and presses a button to see the calculated...
0
by: anaxamandr | last post by:
Hi. I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process. I attempted...
2
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
1
by: cdelaney | last post by:
I have a form that I created a calculation on using 2003. The calculation works exactly like I want it to but ONLY on the first and last record. The calculation does not work/exist on records in...
0
by: gavo | last post by:
Hi. using A2K; i have a form containing a continous subform. The question is, how can i call a calculation for one of the fields in the continous subform from the main form. At the moment i...
4
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the...
4
by: vg-mail | last post by:
Hello all, I have identical design for form and report but I am getting calculation error on form and everything is OK on report. The form and report are build up on SQL statement. The...
5
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
3
by: mattmao | last post by:
Okay, I was asked by a friend about the result of this limit: http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg Not n->zero but n-> + infinite I really...
5
by: =?Utf-8?B?amVsbGU3OQ==?= | last post by:
Hi, I want to use a difficult Excelsheet as source for my calculation in a ASP.NET (C#) page. I have 5 input fields on my ASP.NET page and when I press the submit button I want to put these...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.