|
|
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^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 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 4,294,967,295 (2^32-1) is assumed. The value of "seed" is limited to 0 <= seed <= 2^32. The function value will be between 0 and 2^32.
$$CRC32^XLFCRC(string[,seed])
| string: | (required) String upon which to compute the CRC32. |
| seed: | (optional) Seed value. Needed to compute the CRC32 over multiple strings. |
| returns: | Returns the Cyclic Redundancy Code (CRC) 32 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=$$CRC32^XLFCRC(X(I),C) |
Or
SET I=0,C=4294967295 FOR SET I=$ORDER(X(I)) QUIT:'I DO . SET C=$$CRC32^XLFCRC(X(I),C) |
As long as the save method is used all the time.
CRC322 ;Test call CRC32^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=$$CRC32^XLFCRC(TEXT,CRC) If 715820230=$$CRC32^XLFCRC(TEXT2,CRC) WRITE !,"CRC32 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
|