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

$%CRC32

Draft MDC Standard

3 STRING Library
3.2 CRC32

CRC32(string,seed) ;
	;
	; The code below was approved in document X11/1998–32
	;
	; Polynomial X**32 + X**26 + X**23 + X**22 +
	;          + X**16 + X**12 + X**11 + X**10 +
	;          + X**8  + X**7  + X**5  + X**4 +
	;          + X**2  + X     + 1
	New I,J,R
	If '$Data(seed) Set R=4294967295 ; = 2**32 - 1
	Else  If seed'<0,seed'>4294967295 Set R=4294967295-seed
	Else  Set $ECode=",M28,"
	For I=1:1:$Length(string) Do
	. Set R=$$XOR($Ascii(string,I),R,8)
	. For J=0:1:7 Do
	. . If R#2 Set R=$$XOR(R\2,3988292384,32)
	. . Else  Set R=R\2
	. . Quit
	. Quit
	Quit 4294967295-R ; 32-bit ones complement
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:54:57.

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