|
|
Reference Type: Supported, Category: Other Functions, Integration Agreement: 3156
This extrinsic function computes a Cyclic Redundancy Code (CRC) of the 8-bit character string, using X^16 + X^15 + X^2 + 1 as the polynomial. The optional parameter "seed" may supply an initial value, which allows for running CRC calculations on multiple strings. If the parameter "seed" is not specified, a default value of zero (0) is assumed. The value of "seed" is limited to 0 <= seed <= 2^16. The function value will be between 0 and 2^16.
$$CRC16^XLFCRC(string[,seed])
| string: | (required) String upon which to compute the CRC16. |
|
| seed: |
(optional) Seed value. Needed to compute the CRC16 over multiple strings. |
|
| returns: |
Returns the Cyclic Redundancy Code (CRC) 16 value. |
|
SET CRC=$$CRC32^XLFCRC(string)
A checksum can also be calculated over multiple strings.
SET (I,C)=0 FOR SET I=$ORDER(X(I)) QUIT:'I DO . SET C=$$CRC16^XLFCRC(X(I),C) |
Or
SET I=0,C=4294967295 FOR SET I=$ORDER(X(I)) QUIT:'I DO . SET C=$$CRC16^XLFCRC(X(I),C) |
As long as the save method is used all the time.
CRC162 ;Test call CRC16^XLFCRC multiple times S TEXT="Now is the time for all good children",TEXT2="to come to the aid of their country." S CRC=0,CRC=$$CRC16^XLFCRC(TEXT,CRC) If 23166=$$CRC16^XLFCRC(TEXT2,CRC) WRITE !,"CRC16 OK" Q |
NOTE: These have been approved for inclusion in a future ANSI M language standard as part of the library.
|
VA (Internet) / VA (Intranet) / OI / HSD&D / Site Map / Terms of Use / VA Privacy Policy / Accessibility Reviewed/Updated:
December 14, 2005
|