<?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: Float Point Calculations in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225166#M1379789</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;a type p value '1.100',&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is not the same as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a type p decimals 3 value '1.100',&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Oct 2009 12:17:23 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-10-08T12:17:23Z</dc:date>
    <item>
      <title>Float Point Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225163#M1379786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I do the following in abap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&amp;gt; Snip &amp;lt;-&lt;/P&gt;&lt;P&gt;data: e_faktor type f,&lt;/P&gt;&lt;P&gt;      a like drseg-menge value  '1.100',&lt;/P&gt;&lt;P&gt;      b like drseg-menge value  '2.200',&lt;/P&gt;&lt;P&gt;      c like drseg-menge value  '3.300'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e_faktor = ( a + b - c ).&lt;/P&gt;&lt;P&gt;write e_faktor.&lt;/P&gt;&lt;P&gt;-&amp;gt; Snip &amp;lt;-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the result is 4,4408920985006262E-16.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would expect it to be 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Changing a = 2.2&lt;/P&gt;&lt;P&gt;         b = 2.2&lt;/P&gt;&lt;P&gt;         c = 4.4 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gives me 0 as expected &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I missing something ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2009 11:20:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225163#M1379786</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-08T11:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Float Point Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225164#M1379787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data: e_faktor type f,&lt;/P&gt;&lt;P&gt;a type p value '1.100',&lt;/P&gt;&lt;P&gt;b type p value '2.200',&lt;/P&gt;&lt;P&gt;c type  p value '3.300'.&lt;/P&gt;&lt;P&gt;break developer.&lt;/P&gt;&lt;P&gt;e_faktor = ( a + b ) - c .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write e_faktor.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2009 11:38:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225164#M1379787</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-08T11:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Float Point Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225165#M1379788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dear,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: e_faktor TYPE p DECIMALS 3, "f,&lt;/P&gt;&lt;P&gt;a TYPE p DECIMALS 3 VALUE '1.100',&lt;/P&gt;&lt;P&gt;b TYPE p DECIMALS 3 VALUE '2.200',&lt;/P&gt;&lt;P&gt;c TYPE p DECIMALS 3 VALUE '3.300'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  e_faktor = ( a + b ) - c .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WRITE e_faktor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this will helpful for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2009 12:00:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225165#M1379788</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-08T12:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Float Point Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225166#M1379789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;a type p value '1.100',&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;is not the same as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a type p decimals 3 value '1.100',&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2009 12:17:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225166#M1379789</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-08T12:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Float Point Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225167#M1379790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Vijay,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, that would work , but I would like to know why my example does not work.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is an example of code in a standard SAP function that MRM_ORDER_PRICE_QUANTITY_CHECK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there something wrong with the way Float Points work in SAP ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I expect the following code to give the answer 3.300000000000000E&lt;EM&gt;00 not 3.2999999999999998E&lt;/EM&gt;00 as our is the case in our SAP system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&amp;gt; Snip &amp;lt;-&lt;/P&gt;&lt;P&gt;data: e_faktor type f,&lt;/P&gt;&lt;P&gt;a type p decimals 3 value '3.300'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e_faktor = a.&lt;/P&gt;&lt;P&gt;write e_faktor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-&amp;gt; Snip &amp;lt;-&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2009 12:29:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225167#M1379790</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-08T12:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Float Point Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225168#M1379791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How SAP works: as target is a float field, packed fields are converted to float before the calculation. So we get the problem of rounding.&lt;/P&gt;&lt;P&gt;This kind of problem is inherent to floating point numbers.&lt;/P&gt;&lt;P&gt;The rounding problem is explained and solved in [Note 361784 - Floating point rounding problems|http://service.sap.com/sap/support/notes/361784]. Use method ROUND_F_TO_15_DECS of class CL_ABAP_MATH.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2009 21:41:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225168#M1379791</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2009-10-08T21:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Float Point Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225169#M1379792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Adriaan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;?? just copied your code snippet in SAP ECC 6.0 SAP_BASIS	700 SAP_ABA	700 system:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FORM calc .
  DATA:
    e_faktor TYPE f,
    a LIKE drseg-menge VALUE '1.100',
    b LIKE drseg-menge VALUE '2.200',
    c LIKE drseg-menge VALUE '3.300',
    d  LIKE drseg-menge.

  d        = ( a + b - c ).
  e_faktor = ( a + b - c ).
  SET COUNTRY 'DE'.
  WRITE:/ e_faktor, d.
  SET COUNTRY 'US'.
  WRITE:/ e_faktor, d.
ENDFORM.                    " CALC
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this results in &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  0,0000000000000000E+00            0,000
  0.0000000000000000E+00            0.000
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How did you proceed, what system are you working on?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Oct 2009 22:30:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225169#M1379792</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2009-10-08T22:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Float Point Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225170#M1379793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Clemens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Copy and paste your code with the result below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
4,4408920985006262E-16   0,00
4.4408920985006262E-16   0.00
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;System Information&lt;/P&gt;&lt;P&gt;Kernel Patch number - 247&lt;/P&gt;&lt;P&gt;SAP_BASIS - 620  support pack SAPKB62063&lt;/P&gt;&lt;P&gt;SAP_ABA   - 620  support pack SAPKB62063&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2009 06:55:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225170#M1379793</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-09T06:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Float Point Calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225171#M1379794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Clemens, I also have the same result as Adriaan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The difference between kernels/OS is fun, but it's no more an issue than having float = '1.005' resulting in 1.004999999999999E+00. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All this is normal, it's the general issue of rounding with floating point numbers, and it's not related to ABAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adriaan, if you want fixed point precision, you must use packed numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your example, you must either:&lt;/P&gt;&lt;P&gt;- directly use packed number&lt;/P&gt;&lt;P&gt;- or if you really want a float as result of the calculation, add extra statements transfer float to packed. Remark: the Note 361784 (Floating point rounding problems) I indicated above explains some interesting things but does not solve this "problem" of F which is not exactly zero (this note gives only a solution for transferring a float variable to a packed variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want more information, check wikipedia documentation about floating point and fixed point arithmetic&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Oct 2009 08:49:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/float-point-calculations/m-p/6225171#M1379794</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2009-10-09T08:49:06Z</dc:date>
    </item>
  </channel>
</rss>

