Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

$%CRCCCITT

Draft MDC Standard

3 STRING Library
3.3 CRCCCITT

CRCCCITT(string,seed) ;
	;
	; The code below was approved in document X11/1998–32
	;
	; Polynomial x**16 + x**12 + x**5 + x**0
	New I,J,R
	If '$Data(seed) Set R=65535
	Else  If seed'<0,seed'>65535 Set R=seed\1
	Else  Set $ECode=",M28,"
	For I=1:1:$Length(string) Do
	. Set R=$$XOR($Ascii(string,I)*256,R,16)
	. For J=0:1:7 Do
	. . Set R=R+R
	. . Quit:R<65536
	. . Set R=$$XOR(4129,R–65536,13)
	. . Quit
	. Quit
	Quit R
XOR(a,b,w) New I,M,R
	Set R=b,M=1
	For I=1:1:w Do
	. Set:a\M#2 R=R+$Select(R\M#2:-M,1:M)
	. Set M=M+M
	. Quit
	Quit R
Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.

Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.

This page most recently updated on 16-Nov-2023, 16:55:16.

For comments, contact Ed de Moel (demoel@jacquardsystems.com)