Analyzing encodings

The Encoding field contains subfields; because of this, applications that need to examine the integer, packed decimal, or float encoding must use one of the techniques described.


Use bit operations

If the programming language supports bit operations, perform the following steps:
  1. Select one of the following values, according to the type of encoding required:

    • MQENC_INTEGER_MASK for the binary integer encoding
    • MQENC_DECIMAL_MASK for the packed decimal integer encoding
    • MQENC_FLOAT_MASK for the floating point encoding

    Call the value A.

  2. Combine the Encoding field with A using the bitwise AND operation; call the result B.
  3. B is the encoding required, and can be tested for equality with each of the values that is valid for that type of encoding.


Use arithmetic

If the programming language does not support bit operations, perform the following steps using integer arithmetic:
  1. Select one of the following values, according to the type of encoding required:

    • 1 for the binary integer encoding
    • 16 for the packed decimal integer encoding
    • 256 for the floating point encoding

    Call the value A.

  2. Divide the value of the Encoding field by A ; call the result B.
  3. Divide B by 16; call the result C.
  4. Multiply C by 16 and subtract from B ; call the result D.
  5. Multiply D by A ; call the result E.
  6. E is the encoding required, and can be tested for equality with each of the values that is valid for that type of encoding.

Parent topic: Machine encodings