<?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: Real variables: precision and representation in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Real-variables-precision-and-representation/m-p/788009#M31082</link>
    <description>Overview (one of):&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://en.wikipedia.org/wiki/IEEE_floating-point_standard" target="_blank"&gt;http://en.wikipedia.org/wiki/IEEE_floating-point_standard&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Details (standard itself):&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://grouper.ieee.org/groups/754/" target="_blank"&gt;http://grouper.ieee.org/groups/754/&lt;/A&gt;</description>
    <pubDate>Tue, 20 Jun 2006 19:27:13 GMT</pubDate>
    <dc:creator>Jugoslav_Dujic</dc:creator>
    <dc:date>2006-06-20T19:27:13Z</dc:date>
    <item>
      <title>Real variables: precision and representation</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Real-variables-precision-and-representation/m-p/788008#M31081</link>
      <description>Hello everybody,&lt;BR /&gt;&lt;BR /&gt;When trying out some elementary things with real variables in Fortran-95, I defined 3 real variables x, y and z, of REAL KIND=1, 2 and 3, respectively.&lt;BR /&gt;REAL (KIND=1) :: x&lt;BR /&gt;REAL (KIND=2) :: y&lt;BR /&gt;REAL (KIND=3) :: z&lt;BR /&gt;&lt;BR /&gt;However I got 3 compiler warnings saying:&lt;BR /&gt;&lt;BR /&gt;Specifying the kind of the type REAL with the constant '1' is non-portable - 'SELECTED_REAL_KIND(6,37)' would be better&lt;BR /&gt;Specifying the kind of the type REAL with the constant '2' is non-portable - 'SELECTED_REAL_KIND(15,307)' would be better&lt;BR /&gt;Specifying the kind of the type REAL with the constant '3' is non-portable - 'SELECTED_REAL_KIND(18,4931)' would be better&lt;BR /&gt;&lt;BR /&gt;A little surprised by these "strange" numbers, I started to play around a bit with log10's and log2's to find out about the internal representation of real variables in FTN95.&lt;BR /&gt;&lt;BR /&gt;KIND=1&lt;BR /&gt;---------&lt;BR /&gt;To cover a RANGE from -10^37 to 10^37 we need exactly 8 bits for the exponent (7 databits + 1 signbit).&lt;BR /&gt;To get a PRECISION of 6 decimal digits we need at least 21 bits (20+1) and maximally 24 bits (23+1) for the mantissa.&lt;BR /&gt;So, I guess that a REAL (KIND=1) is represented in 4 bytes with a (24,8)-division between mantisse and exponent.&lt;BR /&gt;In other words: the classical REAL*4.&lt;BR /&gt;So far, so good.&lt;BR /&gt;&lt;BR /&gt;KIND=2&lt;BR /&gt;---------&lt;BR /&gt;To cover a RANGE from -10^307 to 10^307 we need exactly 11 bits for the exponent (10 databits + 1 signbit).&lt;BR /&gt;To get a PRECISION of 15 decimal digits we need at least 51 bits (50+1) and maximally 54 bits (53+1) for the mantissa.&lt;BR /&gt;So, I guess that a REAL (KIND=2) is represented in 8 bytes with a (53,11)-division between mantissa and exponent.&lt;BR /&gt;A rather unexpected division (53,11), but at least we still have the 8-byte representation.&lt;BR /&gt;Or is it rather a (52,12)-division?&lt;BR /&gt;However, with 12 bits for the exponent we could cover the range -10^616 to 10^616.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;But now!&lt;BR /&gt;&lt;BR /&gt;KIND=3&lt;BR /&gt;---------&lt;BR /&gt;To cover a RANGE from -10^4931 to 10^4931 we need exactly 15 bits for the exponent (14 databits + 1 signbit).&lt;BR /&gt;To get a PRECISION of 18 decimal digits we need at least 61 bits (60+1) and maximally 64 bits (63+1) for the mantisse.&lt;BR /&gt;If we assume that the PRECISION and RANGE values as supplied by the compiler are correct, that would imply that a REAL (KIND=3) variabale is represented internally by 76 to 79 bits.&lt;BR /&gt;Since this interval doesn't contain a multiple of 8 I suppose that a REAL (KIND=3) is represented in 10 bytes (REAL*10) with a (64,16)-division between mantissa and exponent.&lt;BR /&gt;However, with 16 bits for the exponent we could cover the range -10^9864 to 10^9864.&lt;BR /&gt;&lt;BR /&gt;I know this is a rather long post, but could anyone confirm the numbers above and the reasoning I have applied?&lt;BR /&gt;Maybe I'm a bit old-fashioned, but I like to know how numbers (and objects in general) are represented internally.&lt;BR /&gt;I guess this is still a result of my assembler adventures in a previous life...&lt;BR /&gt;&lt;BR /&gt;Many thanks for the feedback and the trouble of checking all this!&lt;BR /&gt;Kind regards,&lt;BR /&gt;Lucas.</description>
      <pubDate>Tue, 20 Jun 2006 18:19:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Real-variables-precision-and-representation/m-p/788008#M31081</guid>
      <dc:creator>lucaslehmer</dc:creator>
      <dc:date>2006-06-20T18:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Real variables: precision and representation</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Real-variables-precision-and-representation/m-p/788009#M31082</link>
      <description>Overview (one of):&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://en.wikipedia.org/wiki/IEEE_floating-point_standard" target="_blank"&gt;http://en.wikipedia.org/wiki/IEEE_floating-point_standard&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Details (standard itself):&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://grouper.ieee.org/groups/754/" target="_blank"&gt;http://grouper.ieee.org/groups/754/&lt;/A&gt;</description>
      <pubDate>Tue, 20 Jun 2006 19:27:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Real-variables-precision-and-representation/m-p/788009#M31082</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2006-06-20T19:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Real variables: precision and representation</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Real-variables-precision-and-representation/m-p/788010#M31083</link>
      <description>Many thanks, Jugoslav!&lt;BR /&gt;&lt;BR /&gt;Especially the first link you provided is most clarifying!&lt;BR /&gt;Kind regards,&lt;BR /&gt;Lucas.</description>
      <pubDate>Tue, 20 Jun 2006 22:17:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Real-variables-precision-and-representation/m-p/788010#M31083</guid>
      <dc:creator>lucaslehmer</dc:creator>
      <dc:date>2006-06-20T22:17:48Z</dc:date>
    </item>
  </channel>
</rss>

