OnixS C++ CME Market Data Handler  2.56.0.0
Decimal Type for Manipulating Prices

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 type capacity limits.

Assume the following initialization of a variable of double type is executed:

const double Price = 100.10;

In spite of exact constant definition, the real value, hold by a defined variable, will look like 100.099999999999998, but not 100.1.

This is because each double value is expressed as X * 2 ^ Y, where X is mantissa and Y is 2-basis exponent.

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

Since this Release SDK exposes OnixS::CME::MarketData::Decimal class for better operability over real numbers as prices are.

In contrast to a double type, available as native C++ data type, OnixS::CME::MarketData::Decimal presents real numbers use 10-basis exponent. Therefore, each number looks like X * 10 ^ Y, where X is mantissa and Y is an exponent.

OnixS::CME::MarketData::Decimal class instances can be constructed from native C++ types as well as comparison and conversion operators are exposed for better interoperability.

Note
FIX/FAST Encoding presents price values similar to OnixS::CME::MarketData::Decimal. Switching using OnixS::CME::MarketData::Decimal for prices improves performance characteristics.