Table of contents


In FAST, Decimal numbers are represented by two signed integers, an exponent and mantissa. This is similar to, but not the same as the IEEE standard. FAST variable length encoding differs from IEEE, which has a fixed size encoding of a set number of bytes and other special values, such as infinity.

The numerical value of a decimal data type is obtained by extracting the encoded signed integer exponent followed by the signed integer mantissa values from the encoded message and multiplying the mantissa by base 10 power of the exponent.

output value=mantissa * 10 exponent


Take, for example, the encoded decimal value: 0xFE 0x9 0xD2 = 11111110 00001001 11010010.
Picture 3.20 shows the decoding process of this decimal field.

Decimal value decoding

Picture 3.20 - "Decimal value decoding"

Using these values we calculate complete decimal value.
decimalValue=mantissa * 10 exponent = 1234 * 10 -2 = 12.34


  • The presence attribute of exponent equals to presence attribute of decimal field. Mantissa must always have mandatory presence. Thus the exponent can be either nullable or non-nullable and the mantissa is always non-nullable.
  • The mantissa is present in the stream if the exponent is not NULL.
  • If the template field is optional the field of this data type can have empty value (NULL) and will not be added into the output message. This is represented by a NULL in the exponent (in which case, no mantissa field is encoded or decoded).

Here is the code example:

    public int decode(byte[] bupublic int decode(byte[] buffer, int offset, PresenceMap presenceMap, FIXMessage message) {
        offset = exponentField.decode(buffer, offset, presenceMap, message);
        if (exponentField.getValue() != null) {
            offset = mantissaField.decode(buffer, offset, presenceMap, message);
            Object decimal = calculateDecimalValue(exponentField.getValue(), 
            message.addValue(tagId, decimal);
        return offset;
Lets consider more detailed another example of decimal field decoding:

Our FAST message template:

<template dictionary="2" id="2" name="DecimalDecodingSample_2">
    <decimal id="270" name="MDEntryPx">
            <constant value="-3"></constant>
Note: The presence attribute of our decimal field is specified by our template and it is mandatory. According to the decimal field definition the presence attribute of exponent is the same as presence attribute of full decimal field and is mandatory too. Presence attribute of mantissa is always mandatory.

Input encoded message:

    HEX format:    0xE0 0x81 0x03 0x3B 0xD5
    Binary format: 11100000 10000001 00000011 00111011 11010101

Decoding process of this message is shown below:

Decoding of message which contains decimal field

Picture 3.21 - "Decoding of message which contains decimal field"

After collecting our fields the output message will be: 270=567.89<SOH>