# Instructions & Information about the Arithmetic Encoder/Decoder

## Arithmetic Codes

Data in arithmetic codes are preserved under a set of arithmetic operations. We say that an error code is preserved under an arithmetic operation * if for any two operands X and Y and the corresponding encoded entities X' and Y' there is an operation # for the operands satisfying X' # Y' = (X * Y)'. The results of the arithmetic operation # when applied to the encoded operands X' and Y' will yield the same result as encoding the outcome of applying the original operation * the original operands X and Y.
Arithmetic codes can be sorted into non-separable arithmetic codes and separable arithmetic codes. The simplest non-separable codes is AN codes, and the simplest separable codes is residue codes. AN codes are formed by multiplying the operands by a constant. Residue code are formed by attaching the operands with a separate check symbol, which is the residue of the operands divided by a constant.

## Help with the single word encoder and decoder

The single word encoder calculates the code words of AN codes and Residue codes. The user can make a choice of these two sorts of encoding method. The data words and encoding constants should be binary or hexadecimal numbers of at most 32 bits. The encoded word can be displayed by pushing the encode button. The decoder shows how bit-flip errors of the encoded word can or cannot be detected by comparing the remainder the expected remainder.

## Help with the Addition of X and Y encoder and decoder

This encoder and decoder shows how a error that happens during the process of an adding operation can or cannot be detected. The data words and encoding constants should be binary or hexadecimal numbers of at most 32 bits. All the intermediate numbers are displayed as binary number or should be input as binary numbers. The user can push "calculate next bit" button to get the next bit of the partial sum from the least significant bit to the most significant bit. Errors can be injected by modifying the most significant bit of the carry-ins or by modifying a bit of the encoded words when the order of the most significant bit of the partial sum is less than the order of the modified bit. If the user injected two errors, error cancellation may occur. Here are simple examples:

AN codes:
Input data words and encoding constant:
Data Word X: 11011, Data Word Y: 1100, Encoding Constant: 11
Encoded Word X: 1010001, Encoded Word Y: 100100
Modify the 2nd-order bit of Encoded Word Y
Encoded Word X: 1010001, Encoded Word Y: 100110
Push the "Calculate Next Bit" button for 4 times,
Carry-in: 0000, Partial sum: 0111
Modify the MSB of the carry-in:
Carry-in: 1000, Partial sum: 0111
Push "calculate next bit" button until we get the final sum (Encoded Word Z):
Encoded Word Z: 10000111
Decode the final sum:
Correct Word Z:   100111, Correct Remainder: 0
Decoded Word Z: 101101, Remainder: 0

Residue codes:
Input data words and encoding constant:
Data Word X: 11011, Data Word Y: 1100, Encoding Constant: 3
Encoded Word X: 11011 00, Encoded Word Y: 1100 00
Modify the LSB bit of Encoded Word Y
Encoded Word X: 11011 00, Encoded Word Y: 1101 00
Push the "Calculate Next Bit" button for 4 times,
Carry-in: 1111, Partial sum: 1000
Modify the MSB of the carry-in:
Carry-in: 0111, Partial sum: 1000
Push "calculate next bit" button until we get the final sum (Encoded Word Z):
Encoded Word Z: 011000 00
Decode the final sum:
Correct Word Z:   100111, Correct Remainder: 00
Decoded Word Z: 011000, Remainder: 00

## Help with the Multiplication of X and Y encoder and decoder

This encoder and decoder shows how a error that happens during the process of a multiplying operation can or cannot be detected. The data words and encoding constants should be binary or hexadecimal numbers of at most 32 bits. All the intermediate numbers are displayed as binary number or should be input as binary numbers. The user can push "calculate partial product" button to get the partial product in the text area. Errors can be injected by modifying one or more bits of the partial product. If the user injected two errors, error cancellation may occur. Here are simple examples,

AN codes:
Input data words and encoding constant:
Data Word X: 11011, Data Word Y: 1100, Encoding Constant: 11
Encoded Word X: 1010001, Encoded Word Y: 100100
Push the "Calculate Partial Product" button:
0000000
0000000
1010001
0000000
0000000
1010001
Flip the two red bits:
0000000
0000000
1000001
0000000
0000000
1010000
Calculate the final product (Encoded Word Z):
Encoded Word Z: 101100000100
Decode the final product:
Correct Word Z:   101000100, Correct Remainder: 0
Decoded Word Z: 100111001, Remainder: 0

Residue Codes:
Input data words and encoding constant:
Data Word X: 11011, Data Word Y: 1100, Encoding Constant: 11
Encoded Word X: 11011 00, Encoded Word Y: 1100 00
Push the "Calculate Partial Product" button:
00000
00000
11011
11011
Flip the two red bits:
00000
00000
01011
11010
Calculate the final product (Encoded Word Z):
Encoded Word Z: 11111100 00
Decode the final product:
Correct Word Z: 101000100, Correct Remainder: 00
Decoded Word Z: 11111100, Remainder: 00