Talk:CRC-32: Difference between revisions

(thanks for testing)
 
(32 intermediate revisions by 5 users not shown)
Line 53:
:: I suggest something based on [[wp:Low-density parity-check code|Gallager code]]s would be appropriately beefy, as those are used in very high performance applications like transmissions from satellites. If that doesn't satisfy you, Spekkio, I don't know what will. :-) Different task though. –[[User:Dkf|Donal Fellows]] 17:27, 11 December 2011 (UTC)
::: Thanks, that is very interesting :D --[[User:Spekkio|Spekkio]] 10:02, 12 December 2011 (UTC)
:::: Hamming numbers are the number of inverted bits in a row in the message, plus one in the checksum code, that can go wrong before it can fail to detect the error. So if you had a hamming distance of 6, as in the CRC-15 used by CANbus, then you would have up to five bits in a row that could be wrong, along with one wrong in the checksum itsself. So CANCRC15 has a hammin distance of 6. This means its very good at getting rid of electrical interference on a line: i.e. a burst error of 5 bits or less will be detected. Look up papers by Cooperman for a math description, and lots of deifferent polynomials for CRCs. [[User:Robin48gx|Robin48gx]] ([[User talk:Robin48gx|talk]]) 13:28, 23 September 2014 (UTC)
 
== CRC library ported to several languages ==
Line 76 ⟶ 77:
NUMERIC DIGITS
</pre>
 
:: Is the above a cut 'n paste from a document, or is the '''cd2''' a mere typo? -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 19:02, 18 August 2013 (UTC)
 
I would think that Rexx on VM or TSO would fail as well but have no longer access to try. Anyone else?? --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 05:09, 18 August 2013 (UTC)
:: Could you please run this test on your Rexx(es)?
Line 81 ⟶ 85:
* 18.08.2013 Walter Pachl Test c2d behavior
**********************************************************************/
Parse Version v
Say v
cnt.=0
c=d2c(999999999)
id='001'
If c2x(c)='3B9AC9FF' Then cnt.0ok=cnt.0ok+1
If c2x(c)='3B9AC9FF' Then
Call cnt 'ok'
d=c2d(c)
Signal on Syntax
id='S001'
d1=d2c(d+1)
cnt.0err=cnt.0err+1
BS001:
back:
Signal on Syntax
id='002'
rec=c2d('ffffffff'x)
B002:
id='003'
Numeric Digits 10
say c2d('ffffffff'x)
B003:
id='004'
Numeric Digits 20
say c2d('ffffffffffff'x)
B004:
Say cnt.0ok 'Tests ok'
Say cnt.0err 'Tests failed'
Exit
 
cnt:
Parse Arg x
If x='ok' Then
cnt.0ok=cnt.0ok+1
Else Do
cnt.0err=cnt.0err+1
Say 'Test' id 'failed'
End
Return
 
syntax:
If left(id,1)='S' Then
cnt.0ok=cnt.0ok+1
Call cnt 'ok'
Signal back</lang>
Else
Call cnt id
Signal value('B'id)</lang>
--[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 05:53, 18 August 2013 (UTC)
 
:: Please note that the &nbsp; '''signal value(...''' &nbsp; isn't a valid construct from some older REXXes, &nbsp; so PC/REXX, Personal REXX, and KEXX can't be used for the above REXX program. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 19:10, 18 August 2013 (UTC)
 
-----
Line 101 ⟶ 138:
I don't quite understand the reasoning/logic behind the test program:
: if the program gets a SYNTAX error ''anywhere'', it counts as OK.
:: not anymore --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 19:27, 18 August 2013 (UTC)
: if the program successfully does the two '''D2C'''s, it counts as an error in one case, but not the other.
: if the program successfully does the 2nd '''D2C''', it is counted as an error.
:: that's because it should not do it successfully --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 19:27, 18 August 2013 (UTC)
: no check is made to verify that the value of '''D''' matches the value of the 1st argument (999999999).
:: the result is compared with the value that should be there --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 19:27, 18 August 2013 (UTC)
A &nbsp; &nbsp; '''parse version x; say x''' &nbsp; &nbsp; was added after the 1st statement.
A &nbsp; &nbsp; '''parse version x; say x''' &nbsp; &nbsp; was added (in my version) after the 1st statement.
<br>A &nbsp; &nbsp; '''say 'digits=' digits()''' &nbsp; &nbsp; would be a nice addition.
<br><br>But in any case &nbsp; (all were executed under a Windows/XP DOS window (cmd.exe):<br><br>
'''output''' from Regina &nbsp; (including 3.3, 3.4, 3.5, 3.6, 3.7):
<pre>
REXX-Regina_3.7(MT) 5.00 14 Oct 2012
Line 136 ⟶ 176:
Statement context: D:\crud0.rex, procedure: badwalter
</pre>
ClearlyDifferentially, different REXXes which are different are behaving differently (or indifferently?). -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 08:26, 18 August 2013 (UTC)
 
-----
:: Thanks for testing. The 'test case' was not for any program. (I tested the Rexx compiler for VM and then TSO and used such a framework for all programs. Anyway, you see that not only ooRexx does follow the specs (Regina doesn't!?!) - the "obnoxious" statement is therefore not just for ooRexx. right? If you use primarily Regina you won't notice this "problem" right?? --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 08:54, 18 August 2013 (UTC)
 
::: The word I used was ''innoxious'', not ''obnoxious''. &nbsp; Also, I believe it's considered bad form to change people's quotes (I don't mind the correcting of an obvious misspelling, but not the content) --- especially on the discussion (talk) page. &nbsp; The reason I had the various flavors of Regina listed was that some Regina versions were considering numbers as integers that may or may not be considered integers, &nbsp; i.e.: &nbsp; -.1e7 &nbsp; and &nbsp; 12345678912345 &nbsp; for instance. &nbsp; I don't know where Regina REXX currently stands on this. &nbsp; There was some discussion of this topic in the newsgroup '''comp.lang.rexx''' a few months (or maybe years) back; it had to do with what a user expected (REXX's principle of least astonishment) versus what the REXX standard stated &nbsp; (in both examples, both are clearly integers, but maybe not so much according to '''numeric digits'''.) &nbsp; I used the word ''integers'' instead of ''whole numbers'' 'cause some people where saying (in the newsgroup) that negative numbers weren't whole numbers, and some also stated that zero isn't a whole number. &nbsp; Sheesh! &nbsp; ''Natural numbers'' and ''counting numbers'' were also thrown around rather loosely. &nbsp; It was a lively and animated discussion as I recall. &nbsp; Walter, if you're going to add your comments interspersed within my signed comments, please sign your inserted statements. &nbsp; It appears that I'm contradicting (my bullet points) with myself and it's not clear at all who is stating what. &nbsp; Also, now that the REXX program has changed drastically, my (REXX) output no longer matches anything posted, so the results are meaningless. &nbsp; That's what programming versions are for (version 1, my output; version 2, ...). -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 18:52, 18 August 2013 (UTC)
 
:::: sorry about *noxious (I did not know either word in my restricted English. I tried to respond with a better version. --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 19:27, 18 August 2013 (UTC)
 
::: So Regina would not have passed my test suite. Time to ask for Regina's POV (which I will do when I am back home) --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 09:09, 18 August 2013 (UTC)
:::: I forgot that I've entered a ticket about this in sourceforge on 12 July 2013. Alas no response there yet. Fixing may, however, break existing programs :-( --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 18:08, 18 August 2013 (UTC)
::::: No wonder I "forgot". It was not me :-)
<pre>
bugs:#413] c2d should fail if result > numeric digits
Status: open
Created: Fri Jul 12, 2013 11:44 AM UTC by Julian Levens
Last Updated: Fri Jul 12, 2013 11:44 AM UTC
Owner: nobody
</pre>
--[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 18:13, 18 August 2013 (UTC)
 
-----
 
Perhaps this discussion would be better served where there're more (varied) REXX experts (and REXX authors) hanging around --- [such as the REXX newsgroup, '''comp.lang.rexx''']. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 19:00, 18 August 2013 (UTC)
 
:: the ticket raised by someone else should fit your request. Why can't you accept that Regina is wrong here (according to the standard? According to your tests it's the only Rexx that fails to obey the spec! BTW: I entered a doc ticket for ooRexx now because there is a wrong sentence in the C2D description. --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 19:27, 18 August 2013 (UTC)
 
::: Correction: &nbsp; Regina (all five versions) was ''one'' of REXXes of the four that I tested; &nbsp; two of the tested REXX implementations behaved differently, a small sampling. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 20:10, 18 August 2013 (UTC)
 
::: If you're addressing those statements/questions to me: &nbsp; I don't think that Regina is wrong nor do I think that Regina is right. &nbsp; I don't feel comfortable explaining my philosophy on why or why not I accept (the correctness) of certain REXX implementations --- especially on Rosetta Code, not many REXX authors (coders/writers of REXX interpreters) visit here, as far as I can discern. &nbsp; In the case of Regina REXX, it has its own location for reporting (possible) bugs. &nbsp; I know a lot of REXX authors read (subscribe to) the '''comp.lang.rexx''' newsgroup. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 20:10, 18 August 2013 (UTC)
 
:::: Only ONE Rexx (Regina) did not reject that c2d invocation. Can you please update this line
<lang rexx>
numeric digits 10 /*only needed for ooRexx. */
</lang>
to something like
<lang rexx>
numeric digits 10 /*not needed for Regina. */
</lang>
"In the case of Regina REXX, it has its own location for reporting (possible) bugs."
It has been reported there (on sourceforge)! For other Rexxes there is nothing to report (except that Roo, I think it was, does not behave as the others. --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 20:21, 18 August 2013 (UTC)
 
:: I changed the statement, but I didn't include the comment as Regina REXX may fix/change its behaviour, so the comment may be mute, incorrect, or misleading in the future. -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 20:40, 18 August 2013 (UTC)
 
Thanks for the change. Matter closed with these final words from Regina:
<pre>
[bugs:#413] c2d should fail if result > numeric digits
Status: closed-duplicate
Created: Fri Jul 12, 2013 11:44 AM UTC by Julian Levens
Last Updated: Mon Aug 19, 2013 12:53 AM UTC
Owner: Mark Hessling
Duplicate of [#208]. Due to potential serious breakage in existing Rexx programs,
the current default behaviour of Regina will remain;
ie x2d('3b9aca00') will not raise an error.
However with Regina's OPTIONS STRICT_ANSI this error IS trapped.
Sent from sourceforge.net because you indicated interest in
https://sourceforge.net/p/regina-rexx/bugs/413/
</pre>
Again learned something. --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 05:18, 19 August 2013 (UTC)
 
== Size of example string ==
strlen("The quick brown fox jumps over the lazy dog") is 43.
 
Due to modern processors having specific hardware engines used to calculate CRC's that are 32 bit wide
at a time, such as the cortex M3 arm series, it would be better to have a test string that
is wholly divisible by 4. The current test string has 43 characters. adding a full stop to this
would give a strlen() of 44.
 
Also CRC-16 engines take 16 bit chunks at a time, and would not be compatible with the example string chosen.
 
strlen("The quick brown fox jumps over the lazy dog.") is 44.
cprog out: crc32 of test string <The quick brown fox jumps over the lazy dog.>44 is 1368401385 519025E9
This agrees with feeding 11 32 bit words into the arm cortex CRC engine with it
set to CRC32 and seeded with ~0.
 
[[User:Robin48gx|Robin48gx]] ([[User talk:Robin48gx|talk]]) 10:47, 23 September 2014 (UTC)
 
:*The CRC-32 references given are defined on arbitrary sized strings, not limited to multiples of four.
:*Therefore, an implementation that only supported a multiple of four would not be a correct implementation of this task.
:*Performance issues are typically not the point of Rosetta Code examples. If an implementation is optimized for four byte multiples it's just an optimization irrelevant to the task itself.
:*The example input should therefore purposely ''not'' be a multiple of four.
::&mdash;[[User:dchapes|dchapes]] ([[User talk:dchapes|talk]] | [[Special:Contributions/dchapes|contribs]]) 13:50, 23 September 2014 (UTC)
 
::: Yes I take your points, but 32 and 64 bit words are the norm now, as is increasing integration of
::: common tasks (such as CRCs, multiple ADC readings, zero crossing for motor control). Making this string
::: a little longer makes it compatible with blinding fast hardware circuitry. I think its just keeping up with the times.
::: CRC-32 is often used to validate a block of data, not just transmission lines.:wq --[[User:Robin48gx|Robin48gx]] ([[User talk:Robin48gx|talk]])
 
::::Mind you, they are still shipping shed loads of 16 and 8 bit processors as they are smaller, cheaper and more power efficient ;-)<br>--[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 14:49, 3 October 2014 (UTC)
 
::::Robin48gx, what you say is completely irrelevant for all the reasons I gave. &mdash;[[User:dchapes|dchapes]] ([[User talk:dchapes|talk]] | [[Special:Contributions/dchapes|contribs]]) 18:01, 3 October 2014 (UTC)
Anonymous user