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

$%CRC16

Draft MDC Standard

3 STRING Library
3.1 CRC16

CRC16(string,seed) ;
	;
	; The code below was approved in document X11/1998–32
	;
	; Polynomial x**16 + x**15 + x**2 + x**0
	New I,J,R
	If '$Data(seed) Set R=0
	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),R,8)
	. For J=0:1:7 Do
	. . If R#2 Set R=$$XOR(R\2,40961,16)
	. . Else  Set R=R\2
	. . 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:54:35.

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