Table of contents

 

Integers are represented as stop bit encoded entities.
The stop bit decoding process of integer fields is:

  1. Determine the length by the stop bit algorithm.
  2. Remove stop bit from each byte.
  3. Combine 7-bit words (without stop bits) to determine actual integer.

In addition, a nullable field continues with this processing:

  • If the value is zero (0), the output value is NULL.
  • If the value is positive, subtract 1 from that value to use as the output value.
2.3.6.1.1. Unsigned Integer

Represents unsigned integers using the FAST 7-bit binary encoding.

The example of this decoding process is shown below in Picture 3.18

Unsigned Integer stop bit decoding

Picture 3.18 - "Unsigned Integer stop bit decoding"

Decoding code sample of mandatory fields:

public int processUnInt32Decoding(byte[] buffer, int offset, TemplateFieldValue fieldValue) {
    // The primari value is only 0 as this is unsigned
    long value = 0l;
 
    while (!PresenceMap.hasBitOnPosition(buffer[offset], STOP_BIT_POSTION)) {
        value = (value << 7) | (buffer[offset++]);
    }
    value = (value << 7) | (buffer[offset++] & Byte.MAX_VALUE);
    fieldValue.setFieldValue(value);
    return offset;
}

 

2.3.6.1.2. Signed Integer

Used to represent a signed (+/-) integer using the FAST 7-bit binary encoding.
The following diagram illustrates signed integer decoding of a negative number.

Signed integer stop bit decoding

Picture 3.19 - "Signed integer stop bit decoding"

Decoding code sample of non-nullable fields:

    public int processUnInt32Decoding(byte[] buffer, int offset, TemplateFieldValue fieldValue) {
        // The primari value is only 0 as this is unsigned
        long value = 0l;
        while (!PresenceMap.hasBitOnPosition(buffer[offset], STOP_BIT_POSTION)) {
            value = (value << 7) | (buffer[offset++]);
        }
        value = (value << 7) | (buffer[offset++] & Byte.MAX_VALUE);
 
        if (value == 0) {
            fieldValue.setFieldValue(null);
        } else {
            fieldValue.setFieldValue(value - 1);
        }
        return offset;
    }