<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Can I guarantee precision in casting floating point integer in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Can-I-guarantee-precision-in-casting-floating-point-integers-to/m-p/905565#M11602</link>
    <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/367365"&gt;tim18&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;Wouldn't lrint() and the like solve your problem? This looks more like a C++ than an MKL question.&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Thanks for the reply,&lt;BR /&gt;&lt;BR /&gt;Apologies, I was probably not very clear in specifically relating to the MKL:&lt;BR /&gt;&lt;BR /&gt;When using the mkl vector rounding functions: ?Round, ?Floor et al.  are there cases whereby the nearest integer representation (in single or double form) is not precisely represented, e.g. 0.9999999... == 1 on some machines. If this is the case (which Im not sure it is), would the nearest integer value be slightly over or under, by some error margin, the desired value? If the case could ever be slightly under, then casting to an integer would result in a rounding down (which is what I'm trying to determine; the manuals do not elaborate on the underlying method).&lt;BR /&gt;&lt;BR /&gt;Yes, there are c++ ways of doing this, but they do not apply to the application of the vml methods im referring to, which are more scalable: fast iteration; multicore support; and also can operate in variable precision.&lt;BR /&gt;&lt;BR /&gt;Newton&lt;BR /&gt;--------&lt;/P&gt;</description>
    <pubDate>Mon, 17 Nov 2008 13:22:01 GMT</pubDate>
    <dc:creator>newton_particle</dc:creator>
    <dc:date>2008-11-17T13:22:01Z</dc:date>
    <item>
      <title>Can I guarantee precision in casting floating point integers to int32/64s?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Can-I-guarantee-precision-in-casting-floating-point-integers-to/m-p/905563#M11600</link>
      <description>&lt;P&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:WordDocument&gt; &lt;w:View&gt;Normal&lt;/w:View&gt; &lt;w:Zoom&gt;0&lt;/w:Zoom&gt; &lt;w:TrackMoves /&gt; &lt;w:TrackFormatting /&gt; &lt;w:PunctuationKerning /&gt; &lt;w:ValidateAgainstSchemas /&gt; &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt; &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt; &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt; &lt;w:DoNotPromoteQF /&gt; &lt;w:LidThemeOther&gt;EN-US&lt;/w:LidThemeOther&gt; &lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt; &lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt; &lt;w:Compatibility&gt; &lt;w:BreakWrappedTables /&gt; &lt;w:SnapToGridInCell /&gt; &lt;w:WrapTextWithPunct /&gt; &lt;w:UseAsianBreakRules /&gt; &lt;w:DontGrowAutofit /&gt; &lt;w:SplitPgBreakAndParaMark /&gt; &lt;w:DontVertAlignCellWithSp /&gt; &lt;w:DontBreakConstrainedForcedTables /&gt; &lt;w:DontVertAlignInTxbx /&gt; &lt;w:Word11KerningPairs /&gt; &lt;w:CachedColBalance /&gt; &lt;/w:Compatibility&gt; &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt; &lt;m:mathPr&gt; &lt;m:mathFont m:val="Cambria Math" /&gt; &lt;m:brkBin m:val="before" /&gt; &lt;m:brkBinSub m:val="--" /&gt; &lt;m:smallFrac m:val="off" /&gt; &lt;m:dispDef /&gt; &lt;m:lMargin m:val="0" /&gt; &lt;m:rMargin m:val="0" /&gt; &lt;m:defJc m:val="centerGroup" /&gt; &lt;m:wrapIndent m:val="1440" /&gt; &lt;m:intLim m:val="subSup" /&gt; &lt;m:naryLim m:val="undOvr" /&gt; &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"   DefSemiHidden="true" DefQFormat="false" DefPriority="99"   LatentStyleCount="267"&gt; &lt;w:LsdException Locked="false" Priority="0" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Normal" /&gt; &lt;w:LsdException Locked="false" Priority="9" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="heading 1" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 1" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 2" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 3" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 4" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 5" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 6" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 7" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 8" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 9" /&gt; &lt;w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /&gt; &lt;w:LsdException Locked="false" Priority="10" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Title" /&gt; &lt;w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /&gt; &lt;w:LsdException Locked="false" Priority="11" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /&gt; &lt;w:LsdException Locked="false" Priority="22" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Strong" /&gt; &lt;w:LsdException Locked="false" Priority="20" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /&gt; &lt;w:LsdException Locked="false" Priority="59" SemiHidden="false"    UnhideWhenUsed="false" Name="Table Grid" /&gt; &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /&gt; &lt;w:LsdException Locked="false" Priority="1" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /&gt; &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /&gt; &lt;w:LsdException Locked="false" Priority="34" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /&gt; &lt;w:LsdException Locked="false" Priority="29" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Quote" /&gt; &lt;w:LsdException Locked="false" Priority="30" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="19" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /&gt; &lt;w:LsdException Locked="false" Priority="21" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /&gt; &lt;w:LsdException Locked="false" Priority="31" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /&gt; &lt;w:LsdException Locked="false" Priority="32" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /&gt; &lt;w:LsdException Locked="false" Priority="33" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Book Title" /&gt; &lt;w:LsdException Locked="false" Priority="37" Name="Bibliography" /&gt; &lt;w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /&gt; &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face 	{font-family:Verdana; 	panose-1:2 11 6 4 3 5 4 4 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:536871559 0 0 0 415 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0cm; 	margin-right:0cm; 	margin-bottom:10.0pt; 	margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-ansi-language:EN-GB;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page Section1 	{size:612.0pt 792.0pt; 	margin:72.0pt 72.0pt 72.0pt 72.0pt; 	mso-header-margin:35.4pt; 	mso-footer-margin:35.4pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt;&lt;!--[if gte mso 10]&gt; &lt;mce:style&gt;&lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin-top:0cm; 	mso-para-margin-right:0cm; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;} --&gt; &lt;!--[endif]--&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN style="font-size: 9pt; font-family: " verdana=""&gt;If I have an integer value represented in single or double form  what is the best method to cast this value to an int without loss of precision?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN style="font-size: 9pt; font-family: " verdana=""&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN style="font-size: 9pt; font-family: " verdana=""&gt;Case::Example&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN style="font-size: 9pt; font-family: " verdana=""&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;[cpp]      float dis = 2.9999F;&lt;BR /&gt;      int answer = (dis * 10.0000001);&lt;BR /&gt;      std::cout &amp;lt;&amp;lt; answer &amp;lt;&amp;lt; std::endl;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;// Output: 29[/cpp]&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt;In this case, for whatever reason the float has lost some precision, or is unable to precisely represent the true integer value (3)  so when a cast is made, the default action is to round down... hence the answer being 29 and not 30.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt;What I want to do is guarantee that the cast in the operation will return 30 and not 29.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt;What Im wondering is:  if I used v?Round to first round the float/double to the nearest integer value, within the types range/representation, and then cast that value to an int, would I be guaranteed to always get the appropriate closest integer value? Or are there simply cases whereby even v?Round can only approximate an integer value, and the cast will always round down?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt;Newton&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt;----------&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Nov 2008 19:48:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Can-I-guarantee-precision-in-casting-floating-point-integers-to/m-p/905563#M11600</guid>
      <dc:creator>newton_particle</dc:creator>
      <dc:date>2008-11-14T19:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can I guarantee precision in casting floating point integer</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Can-I-guarantee-precision-in-casting-floating-point-integers-to/m-p/905564#M11601</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/406441"&gt;newton_particle&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:WordDocument&gt; &lt;w:View&gt;Normal&lt;/w:View&gt; &lt;w:Zoom&gt;0&lt;/w:Zoom&gt; &lt;w:TrackMoves /&gt; &lt;w:TrackFormatting /&gt; &lt;w:PunctuationKerning /&gt; &lt;w:ValidateAgainstSchemas /&gt; &lt;w:SaveIfXMLInvalid&gt;false&lt;/w:SaveIfXMLInvalid&gt; &lt;w:IgnoreMixedContent&gt;false&lt;/w:IgnoreMixedContent&gt; &lt;w:AlwaysShowPlaceholderText&gt;false&lt;/w:AlwaysShowPlaceholderText&gt; &lt;w:DoNotPromoteQF /&gt; &lt;w:LidThemeOther&gt;EN-US&lt;/w:LidThemeOther&gt; &lt;w:LidThemeAsian&gt;X-NONE&lt;/w:LidThemeAsian&gt; &lt;w:LidThemeComplexScript&gt;X-NONE&lt;/w:LidThemeComplexScript&gt; &lt;w:Compatibility&gt; &lt;w:BreakWrappedTables /&gt; &lt;w:SnapToGridInCell /&gt; &lt;w:WrapTextWithPunct /&gt; &lt;w:UseAsianBreakRules /&gt; &lt;w:DontGrowAutofit /&gt; &lt;w:SplitPgBreakAndParaMark /&gt; &lt;w:DontVertAlignCellWithSp /&gt; &lt;w:DontBreakConstrainedForcedTables /&gt; &lt;w:DontVertAlignInTxbx /&gt; &lt;w:Word11KerningPairs /&gt; &lt;w:CachedColBalance /&gt; &lt;/w:Compatibility&gt; &lt;w:BrowserLevel&gt;MicrosoftInternetExplorer4&lt;/w:BrowserLevel&gt; &lt;m:mathPr&gt; &lt;m:mathFont m:val="Cambria Math" /&gt; &lt;m:brkBin m:val="before" /&gt; &lt;m:brkBinSub m:val="--" /&gt; &lt;m:smallFrac m:val="off" /&gt; &lt;m:dispDef /&gt; &lt;m:lMargin m:val="0" /&gt; &lt;m:rMargin m:val="0" /&gt; &lt;m:defJc m:val="centerGroup" /&gt; &lt;m:wrapIndent m:val="1440" /&gt; &lt;m:intLim m:val="subSup" /&gt; &lt;m:naryLim m:val="undOvr" /&gt; &lt;/m:mathPr&gt;&lt;/w:WordDocument&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; &lt;w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"   DefSemiHidden="true" DefQFormat="false" DefPriority="99"   LatentStyleCount="267"&gt; &lt;w:LsdException Locked="false" Priority="0" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Normal" /&gt; &lt;w:LsdException Locked="false" Priority="9" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="heading 1" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /&gt; &lt;w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 1" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 2" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 3" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 4" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 5" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 6" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 7" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 8" /&gt; &lt;w:LsdException Locked="false" Priority="39" Name="toc 9" /&gt; &lt;w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /&gt; &lt;w:LsdException Locked="false" Priority="10" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Title" /&gt; &lt;w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /&gt; &lt;w:LsdException Locked="false" Priority="11" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /&gt; &lt;w:LsdException Locked="false" Priority="22" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Strong" /&gt; &lt;w:LsdException Locked="false" Priority="20" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /&gt; &lt;w:LsdException Locked="false" Priority="59" SemiHidden="false"    UnhideWhenUsed="false" Name="Table Grid" /&gt; &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /&gt; &lt;w:LsdException Locked="false" Priority="1" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /&gt; &lt;w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /&gt; &lt;w:LsdException Locked="false" Priority="34" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /&gt; &lt;w:LsdException Locked="false" Priority="29" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Quote" /&gt; &lt;w:LsdException Locked="false" Priority="30" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /&gt; &lt;w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /&gt; &lt;w:LsdException Locked="false" Priority="19" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /&gt; &lt;w:LsdException Locked="false" Priority="21" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /&gt; &lt;w:LsdException Locked="false" Priority="31" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /&gt; &lt;w:LsdException Locked="false" Priority="32" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /&gt; &lt;w:LsdException Locked="false" Priority="33" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Book Title" /&gt; &lt;w:LsdException Locked="false" Priority="37" Name="Bibliography" /&gt; &lt;w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /&gt; &lt;/w:LatentStyles&gt; &lt;/xml&gt;&lt;![endif]--&gt;&lt;!--  /* Font Definitions */  @font-face 	{font-family:"Cambria Math"; 	panose-1:2 4 5 3 5 4 6 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:roman; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face 	{font-family:Calibri; 	panose-1:2 15 5 2 2 2 4 3 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face 	{font-family:Verdana; 	panose-1:2 11 6 4 3 5 4 4 2 4; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:536871559 0 0 0 415 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-unhide:no; 	mso-style-qformat:yes; 	mso-style-parent:""; 	margin-top:0cm; 	margin-right:0cm; 	margin-bottom:10.0pt; 	margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi; 	mso-ansi-language:EN-GB;} .MsoChpDefault 	{mso-style-type:export-only; 	mso-default-props:yes; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:Calibri; 	mso-fareast-theme-font:minor-latin; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin; 	mso-bidi-font-family:"Times New Roman"; 	mso-bidi-theme-font:minor-bidi;} .MsoPapDefault 	{mso-style-type:export-only; 	margin-bottom:10.0pt; 	line-height:115%;} @page Section1 	{size:612.0pt 792.0pt; 	margin:72.0pt 72.0pt 72.0pt 72.0pt; 	mso-header-margin:35.4pt; 	mso-footer-margin:35.4pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&gt;&lt;!--[if gte mso 10]&gt; &lt;mce:style&gt;&lt;!   /* Style Definitions */  table.MsoNormalTable 	{mso-style-name:"Table Normal"; 	mso-tstyle-rowband-size:0; 	mso-tstyle-colband-size:0; 	mso-style-noshow:yes; 	mso-style-priority:99; 	mso-style-qformat:yes; 	mso-style-parent:""; 	mso-padding-alt:0cm 5.4pt 0cm 5.4pt; 	mso-para-margin-top:0cm; 	mso-para-margin-right:0cm; 	mso-para-margin-bottom:10.0pt; 	mso-para-margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:"Calibri","sans-serif"; 	mso-ascii-font-family:Calibri; 	mso-ascii-theme-font:minor-latin; 	mso-fareast-font-family:"Times New Roman"; 	mso-fareast-theme-font:minor-fareast; 	mso-hansi-font-family:Calibri; 	mso-hansi-theme-font:minor-latin;} --&gt; &lt;!--[endif]--&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN style="font-size: 9pt; font-family: " verdana=""&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN style="font-size: 9pt; font-family: " verdana=""&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN style="font-size: 9pt; font-family: " verdana=""&gt;Case::Example&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN style="font-size: 9pt; font-family: " verdana=""&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;/EM&gt;&lt;PRE&gt;&lt;EM&gt;[cpp]      float dis = 2.9999F;&lt;BR /&gt;      int answer = (dis * 10.0000001);&lt;BR /&gt;      std::cout &amp;lt;&amp;lt; answer &amp;lt;&amp;lt; std::endl;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;// Output: 29[/cpp]&lt;/EM&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt;What I want to do is guarantee that the cast in the operation will return 30 and not 29.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"&gt;&lt;SPAN lang="EN-GB"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Wouldn't lrint() and the like solve your problem? This looks more like a C++ than an MKL question.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Nov 2008 19:19:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Can-I-guarantee-precision-in-casting-floating-point-integers-to/m-p/905564#M11601</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2008-11-15T19:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Can I guarantee precision in casting floating point integer</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Can-I-guarantee-precision-in-casting-floating-point-integers-to/m-p/905565#M11602</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/367365"&gt;tim18&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;
&lt;P&gt;Wouldn't lrint() and the like solve your problem? This looks more like a C++ than an MKL question.&lt;/P&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;Thanks for the reply,&lt;BR /&gt;&lt;BR /&gt;Apologies, I was probably not very clear in specifically relating to the MKL:&lt;BR /&gt;&lt;BR /&gt;When using the mkl vector rounding functions: ?Round, ?Floor et al.  are there cases whereby the nearest integer representation (in single or double form) is not precisely represented, e.g. 0.9999999... == 1 on some machines. If this is the case (which Im not sure it is), would the nearest integer value be slightly over or under, by some error margin, the desired value? If the case could ever be slightly under, then casting to an integer would result in a rounding down (which is what I'm trying to determine; the manuals do not elaborate on the underlying method).&lt;BR /&gt;&lt;BR /&gt;Yes, there are c++ ways of doing this, but they do not apply to the application of the vml methods im referring to, which are more scalable: fast iteration; multicore support; and also can operate in variable precision.&lt;BR /&gt;&lt;BR /&gt;Newton&lt;BR /&gt;--------&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2008 13:22:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Can-I-guarantee-precision-in-casting-floating-point-integers-to/m-p/905565#M11602</guid>
      <dc:creator>newton_particle</dc:creator>
      <dc:date>2008-11-17T13:22:01Z</dc:date>
    </item>
  </channel>
</rss>

