Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples
Left Hand Pointer


M[UMPS] by Example

Right Hand Pointer

Approved for inclusion in a future M[UMPS] language standard as part of the library for cyclic redundancy checks.

This function computes a Cyclic Redundancy Code of the 8-bit character string string, using X32 + X26 + X23 + X22 + X16 + X12 + X11 + X10 + X8 + X7 + X5 + X4 + X2 + 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 (232–1) is assumed. The value of seed is limited to 0 ≤ seed < 232. The function value will be between 0 and 232.

A typical method of transmitting data is to send data followed by a check-sum value, e.g.:

 Read Data Set L=$Length(Data)
 Set CRC=$Extract(Data,L–1,L)
 Set VAL=0
 For i=1:1:4 Set VAL=VAL*256+$ASCII(CRC,i)
 Set DATA=$Extract(Data,1,L–4)
 If $%CRC32^STRING(Data)'=VAL Do Error

A check-sum can also be calculated over multiple strings:

 For  Set I=$Order(X(I)) Quit:'I  Do
 . Set C=$%CRC32^STRING(X(I),C)
Reference   Value
$%CRC32^STRING(123)   2286445522
$%CRC32^STRING(1234)   2615402659
$%CRC32^STRING(12345)   3421846044
$%CRC32^STRING(" ")   3916222277
$%CRC32^STRING("1234567890123456789012345678901234567890")   2467271962
$%CRC32^STRING("a")   3904355907
$%CRC32^STRING("abc")   891568578
$%CRC32^STRING("abcd")   3984772369
$%CRC32^STRING("abcdef")   1267612143
$%CRC32^STRING("abcdefghijklmnopqrstuvwxyz")   1277644989

The MDC has approved code to approximate the return value of this function. Implementors are encouraged to provide more accurate and efficient code).
Click here for $%CRC32^STRING sample code to view or download the code for this function.
Click here for AllFunctions to view or download the code for all M[UMPS] Library Functions.

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-2019 MUMPS Development Committee;
Copyright © Examples: 1995-2019 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2019 Ed de Moel.

The information in this page is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.

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 12-Sep-2014, 12:53:29 .

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