<?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: data type F in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-type-f/m-p/9713696#M1770372</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;&lt;/P&gt;&lt;P&gt;Here is what it says in ABAP documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Floating point numbers - type F&lt;/LI&gt;&lt;/UL&gt;&lt;DIR style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; background-color: #ffffff; margin-top: 0 !important; margin-bottom: 0 !important;"&gt;&lt;P style="background-color: inherit !important; font-size: 0.8em !important;"&gt;The value range of type F numbers is 1x10**-307 to 1x10**308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the &lt;SPAN style="background-color: inherit !important;"&gt;&lt;STRONG&gt;floating point&lt;/STRONG&gt;&lt;/SPAN&gt; arithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: inherit !important; font-size: 0.8em !important;"&gt;It clearly mentions that the accuracy when using type F is appoximately &lt;STRONG&gt;15 decimals.&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: inherit !important; font-size: 0.8em !important;"&gt;Regards,&lt;/P&gt;&lt;P style="background-color: inherit !important; font-size: 0.8em !important;"&gt;Philip.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIR&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Aug 2013 02:38:55 GMT</pubDate>
    <dc:creator>philipdavy</dc:creator>
    <dc:date>2013-08-22T02:38:55Z</dc:date>
    <item>
      <title>data type F</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-type-f/m-p/9713695#M1770371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Can some explain to me why below result is 9.2249999999999999E-01, not 9.225E-01?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52"&gt;DATA: l_calc_base &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;f.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; l_calc_base &lt;SPAN class="L0S55"&gt;= &lt;SPAN class="L0S55"&gt;( &lt;/SPAN&gt;2008.00 &lt;SPAN class="L0S70"&gt;- 163.00&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;) &lt;/SPAN&gt;/ 2000.00.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 02:02:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-type-f/m-p/9713695#M1770371</guid>
      <dc:creator>former_member48736</dc:creator>
      <dc:date>2013-08-22T02:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: data type F</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-type-f/m-p/9713696#M1770372</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;&lt;/P&gt;&lt;P&gt;Here is what it says in ABAP documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Floating point numbers - type F&lt;/LI&gt;&lt;/UL&gt;&lt;DIR style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 14px; background-color: #ffffff; margin-top: 0 !important; margin-bottom: 0 !important;"&gt;&lt;P style="background-color: inherit !important; font-size: 0.8em !important;"&gt;The value range of type F numbers is 1x10**-307 to 1x10**308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the &lt;SPAN style="background-color: inherit !important;"&gt;&lt;STRONG&gt;floating point&lt;/STRONG&gt;&lt;/SPAN&gt; arithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: inherit !important; font-size: 0.8em !important;"&gt;It clearly mentions that the accuracy when using type F is appoximately &lt;STRONG&gt;15 decimals.&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: inherit !important; font-size: 0.8em !important;"&gt;Regards,&lt;/P&gt;&lt;P style="background-color: inherit !important; font-size: 0.8em !important;"&gt;Philip.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIR&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 02:38:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-type-f/m-p/9713696#M1770372</guid>
      <dc:creator>philipdavy</dc:creator>
      <dc:date>2013-08-22T02:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: data type F</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-type-f/m-p/9713697#M1770373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jiangang You,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN class="L0S52"&gt;DATA: l_calc_base &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;f.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; l_calc_base &lt;SPAN class="L0S55"&gt;= &lt;SPAN class="L0S55"&gt;( &lt;/SPAN&gt;2008 &lt;SPAN class="L0S70"&gt;- 163 &lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;) &lt;/SPAN&gt;/ 2000.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result is 9.2249999999999999E-01&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2&gt;&lt;SPAN style="color: #000080; font-size: 14pt;"&gt; Floating Point Numbers &lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN style="color: #000080; font-size: 14pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; The data type for &lt;A href="http://help.sap.com/abapdocu_70/en/ABENFLOATING_POINT_NUMBER_2_GLOSRY.htm" style="color: #505050;"&gt;floating point numbers&lt;/A&gt; &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;f&lt;/STRONG&gt;&lt;/SPAN&gt; has a &lt;A href="http://help.sap.com/abapdocu_70/en/ABENVALUE_RANGE_GLOSRY.htm" style="color: #505050;"&gt;value range&lt;/A&gt; of2,2250738585072014E-308 to 1,7976931348623157E+308,&lt;SPAN style="color: #008000;"&gt; &lt;STRONG&gt;positive as well as negative, and the number 0, with an accuracy of at least 15 decimal places. &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; You cannot enter floating point numbers directly in your program. Instead, you have to use &lt;A href="http://help.sap.com/abapdocu_70/en/ABENTEXT_LITERAL_GLOSRY.htm" style="color: #505050;"&gt;text literals&lt;/A&gt; that can be interpreted as floating point numbers, that is, contains a number in &lt;A href="http://help.sap.com/abapdocu_70/en/ABENSCIENTIFIC_NOTATION_GLOSRY.htm" style="color: #505050;"&gt;scientific notation&lt;/A&gt;. &lt;A href="http://help.sap.com/abapdocu_70/en/ABENMATHEMATICAL_NOTATION_GLOSRY.htm" style="color: #505050;"&gt;Mathematical&lt;/A&gt; or &lt;A href="http://help.sap.com/abapdocu_70/en/ABENCOMMERCIAL_NOTATION_GLOSRY.htm" style="color: #505050;"&gt;commercial notation&lt;/A&gt; are not permitted unless they can be interpreted as scientific notation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;A href="http://help.sap.com/abapdocu_70/en/ABENARITHMETIC_EXPRESSION_GLOSRY.htm" style="color: #505050;"&gt;Arithmetic expressions&lt;/A&gt; with &lt;A href="http://help.sap.com/abapdocu_70/en/ABENCALCULATION_TYPE_GLOSRY.htm" style="color: #505050;"&gt;calculation type&lt;/A&gt; &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;f&lt;/STRONG&gt;&lt;/SPAN&gt; are performed using &lt;A href="http://help.sap.com/abapdocu_70/en/ABENFLOATING_POINT_ARITH_GLOSRY.htm" style="color: #505050;"&gt;floating point arithmetic&lt;/A&gt;. Use this if you need a very large value range or you are making decimal calculations, but be aware of the following features of floating point arithmetic. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Internally, the exponent and the mantissa of floating point numbers are stored separately, each in two parts. This can lead to unexpected results, despite the high degree of intrinsic accuracy. These occur mainly when performing conversions from and to type &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;f&lt;/STRONG&gt;&lt;/SPAN&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;For example, the number 1.5 can be represented exactly in this notation since 1.5 = 1*2**0 + 1*2**(-1), but the number 0.15 can only be represented approximately by the number 0,14999999999999999. If you round 0.15 up to 1 valid digit, the result is 0.1 rather than 0.2 you would expect. On the other hand, the number 1,5E-12 is represented by the number 1,5000000000000001E-12, which would be rounded up to 2E-12.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Another example that actually occurred is the calculation of 7.27% of 73050 to an accuracy of 2 decimal places. The intermediate result is 5.3107349999999997E+03, since the correct result, 5310.735 cannot be represented exactly in two parts with 53 bits. (If the hardware cannot represent a real number exactly, it uses the next representable floating point number). After rounding, you therefore get 5310.73, rather than 5310.74 as you would expect.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; The ABAP runtime environment always calculates commercially and not numerically like the underlying machine arithmetic. According to the rounding algorithm of the latter, the end digit 5 must always be rounded to the nearest even number (not the next largest number), that is, from 2.5 to 2, 3.5 to 4.&amp;nbsp; &lt;/P&gt;&lt;P&gt; You should also note that multiplication using powers of 10 (positive or negative) is not an exact operation. &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;For example, although it can be represented exactly in two parts, a floating point number &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;F&lt;/STRONG&gt;&lt;/SPAN&gt; of value 100.5, after the operation &lt;BR /&gt; &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;F = F / 100 * 100.&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;BR /&gt;it has the value 100.49999999999999.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; As well as rounding errors, the restricted number of decimal places for the mantissa can lead to the loss of trailing digits. &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;For example, &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;1 - 1,0000000000000001&lt;/STRONG&gt;&lt;/SPAN&gt; results in zero.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt; This means you cannot rely on the last digits in floating point arithmetic. In particular, you should not usually test two floating point numbers &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;a&lt;/STRONG&gt;&lt;/SPAN&gt; and &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt; b&lt;/STRONG&gt;&lt;/SPAN&gt; for equality; instead, you should check whether the relative difference &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&lt;STRONG&gt;abs((a - b)/a)&lt;/STRONG&gt;&lt;/SPAN&gt; is less than a predefined limit, such as 10**(-7). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See this link &lt;A class="active_link" href="http://help.sap.com/abapdocu_70/en/ABENNUMBER_TYPES.htm" title="http://help.sap.com/abapdocu_70/en/ABENNUMBER_TYPES.htm"&gt;http://help.sap.com/abapdocu_70/en/ABENNUMBER_TYPES.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the reason for getting &lt;STRONG&gt;9.2249999999999999E-01&lt;/STRONG&gt;, not &lt;STRONG&gt;9.225E-01.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ramesh.T&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2013 03:19:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-type-f/m-p/9713697#M1770373</guid>
      <dc:creator>former_member209120</dc:creator>
      <dc:date>2013-08-22T03:19:39Z</dc:date>
    </item>
  </channel>
</rss>

