82 lines
6.6 KiB
HTML
82 lines
6.6 KiB
HTML
<!-- HTML header for doxygen 1.8.11-->
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.11"/>
|
|
<title>OnixS C++ CME Market Data Handler: Pages/ManipulatingPrices.md Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<link href="onixs-doxygen.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript">
|
|
$(window).scroll(function() {
|
|
if ($(this).scrollTop() > 1)
|
|
{
|
|
$('header').addClass("sticky");
|
|
}
|
|
else
|
|
{
|
|
$('header').removeClass("sticky");
|
|
}
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectlogo"><a href="http://www.onixs.biz"><img alt="Logo" src="onixs.svg"/></a></td>
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">OnixS C++ CME Market Data Handler
|
|
 <span id="projectnumber">4.8.0.10</span>
|
|
</div>
|
|
<div id="projectbrief">API documentation</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</header>
|
|
<div id="wrapper">
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.11 -->
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Home</span></a></li>
|
|
<li><a href="modules.html"><span>Contents</span></a></li>
|
|
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="navrow2" class="tabs2">
|
|
<ul class="tablist">
|
|
<li><a href="files.html"><span>File List</span></a></li>
|
|
<li><a href="globals.html"><span>File Members</span></a></li>
|
|
</ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Pages/ManipulatingPrices.md</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<a href="ManipulatingPrices_8md.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> \addtogroup new-price-type </div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> </div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> \brief Important aspects of working with decimal numbers like prices. </div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> </div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> Manipulating prices as values of `double` type may lead to calculation </div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> mistakes caused by the way real numbers are presented in `double` values </div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> as well as due to the type capacity limits. </div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> </div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> Assume the following initialization of a variable of the `double` type is executed:</div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> </div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> ~~~{.cpp}</div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> const double Price = 100.10;</div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> ~~~</div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> </div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> In spite of exact constant definition, the real value, hold by a defined variable, </div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> looks like `100.099999999999998`, but not `100.1`.</div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> </div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> This is because each double value is expressed as `X * 2 ^ Y`, where </div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> `X` is mantissa and `Y` is 2-basis exponent.</div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> </div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> As a result, each time the price field is accessed, conversion mistakes might happen.</div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> </div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> Since recently, CME MDP uses a real number with a fixed decimal exponent. </div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> Therefore, the SDK exposes the OnixS::CME::MDH::FixPointDecimal class for </div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> a better experience with original data, transmitted by MDP, and to avoid </div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> issues described above. </div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span> </div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> In contrast to a `double` type, available as a native C++ data type, </div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> the OnixS::CME::MDH::FixedPointDecimal class presents real numbers with </div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> the constant 10-basis exponent. Therefore, each number looks like </div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span> `X * 10 ^ Y`, where `X` is a mantissa and `Y` is an exponent.</div></div><!-- fragment --></div><!-- contents -->
|
|
<!-- HTML footer for doxygen 1.8.11-->
|
|
<!-- start footer part -->
|
|
<footer>
|
|
<hr class="footer"/>
|
|
<address class="footer">
|
|
<small>© <a href="http://www.onixs.biz">Onix Solutions [On<span class="corporate-orange">i</span>x<span class="corporate-orange">S</span>]</a>. All rights reserved.</small>
|
|
</address>
|
|
</footer>
|
|
</div> <!-- wrapper -->
|
|
</body>
|
|
</html>
|