Decimal type

Manipulating prices as values of `double`

type may lead to calculation mistakes caused by the way real numbers are presented in `double`

values as well as due to the type capacity limits.

Let's assume the following initialization of a variable of the `double`

type is executed:

const double Price = 100.10f;

Despite the constant definition, the real value held by the variable, is `100.099999999999998`

, not `100.1`

.

The reason is the following: each `double`

value is expressed as `X * 2 ^ Y`

, where `X`

is mantissa and `Y`

is 2-basis exponent.

As a result, conversion mistakes might happen each time the price field is accessed.

CME MDP 3.0 uses real numbers with a fixed decimal exponent. The SDK exposes the OnixS::CME::MDH::Decimal class to match the data transmitted by MDP and avoid the abovementioned issues.

The OnixS::CME::MDH::Decimal class presents real numbers with the 10-basis exponent. Therefore, each number looks like `X * 10 ^ Y`

, where `X`

is a mantissa and `Y`

is an exponent.