473,396 Members | 1,989 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,396 software developers and data experts.

CRC table caluclation problems

Hi,

I'm trying to implement a 32bit Table based CRC caluclator based on the
guidelines in this
http://thorkildsen.no/faqsys/docs/crc.txt document. However I have run into
a small
"problem" that's made me think. When I create my CRC class I want to
precalculate the
crc table and acording to the document I should get the MSB of the byte in
question, check
if it is a 1 and if so XOR the byte, if not continue. Obviously I need to
keep shifting the byte
to the left to keep getting the "MSB" but when I shift left I get obvious
wrong precalculated
values, but when I shift right and mask the LSB bit I get what appears to be
valid
precaluclated values.

Could anyone explain WHY i should shift right and keep checkin the LSB when
the docs
claim to shift left and check the MSB ?

Here is the code I'm working on.

NOTE: this.poly is of type uint and this.table is a uint[256] array

public class CRC
{
private uint poly;
private uint[] table;

public CRC(uint poly)
{
this.poly = poly;
this.table = new uint[256];
uint indexValue = 0;

for(int index=0; index<256; index++)
{
indexValue = (uint)index;
for(int bit=7; bit>=0; bit--)
{
// THIS WORKS
if( (indexValue & 0x0000001) == 1 )
indexValue = (uint)((indexValue >> 1) ^ this.poly);
else
indexValue = (uint)(indexValue >> 1);

// THIS GIVES STRANGE VALUES
// if( (indexValue & 0x1000000) == 1 )
// indexValue = (uint)((indexValue << 1) ^
this.poly);
//else
// indexValue = (uint)(indexValue << 1);
}
this.table[index] = indexValue;
Console.WriteLine(String.Format("{0:X8}",
this.table[index]));
}
}
}

--
ANDREAS HÅKANSSON
STUDENT OF SOFTWARE ENGINEERING
andreas (at) selfinflicted.org
Nov 15 '05 #1
0 2148

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

Similar topics

61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
7
by: Richard Lawrence | last post by:
Hi, Consider the following: #Content { margin:0px 210px 50px 200px; padding:10px; } If I use it with the following HTML:
10
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
17
by: Jon Ole Hedne | last post by:
I have worked on this problem some hours now (read many-many...), and I can't solve it: In vba-code I create a table with Connection.Execute, and add some data to it. This table is saved in the...
3
by: Adriaan van Heerden | last post by:
hi, once again apologies if I'm covering old ground. I've looked through lots of previous posts and tried some code but nothing works as yet. However, the problem must be a very common one so...
4
by: deko | last post by:
I've heard it's best not to have any formatting specified for Table fields (except perhaps Currency), and instead set the formatting in the Form or Report. But what about Yes/No fields? When I...
3
by: Marina | last post by:
I am using Access 2002. I have a client transactions table with a field for HoursBilled, BillingRate, and AmountBilled. Amount Billed is a caluclation of HoursBilled * BillingRate. I can get...
7
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get...
3
by: Rahul B | last post by:
Hi, I have a user UCLDEV1 which is a part of staff and a group(db2schemagrp1) to which i have not given any permissions. The authorizations of that user are shown as db2 =get authorizations...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.