Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

162 lines
7.8KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Floating Point (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Floating Point (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Floating Point (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Target-Macros.html#Target-Macros" rel="up" title="Target Macros">
  30. <link href="Mode-Switching.html#Mode-Switching" rel="next" title="Mode Switching">
  31. <link href="VMS-Debug.html#VMS-Debug" rel="prev" title="VMS Debug">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Floating-Point"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Mode-Switching.html#Mode-Switching" accesskey="n" rel="next">Mode Switching</a>, Previous: <a href="Debugging-Info.html#Debugging-Info" accesskey="p" rel="prev">Debugging Info</a>, Up: <a href="Target-Macros.html#Target-Macros" accesskey="u" rel="up">Target Macros</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Cross-Compilation-and-Floating-Point"></a>
  68. <h3 class="section">18.22 Cross Compilation and Floating Point</h3>
  69. <a name="index-cross-compilation-and-floating-point"></a>
  70. <a name="index-floating-point-and-cross-compilation"></a>
  71. <p>While all modern machines use twos-complement representation for integers,
  72. there are a variety of representations for floating point numbers. This
  73. means that in a cross-compiler the representation of floating point numbers
  74. in the compiled program may be different from that used in the machine
  75. doing the compilation.
  76. </p>
  77. <p>Because different representation systems may offer different amounts of
  78. range and precision, all floating point constants must be represented in
  79. the target machine&rsquo;s format. Therefore, the cross compiler cannot
  80. safely use the host machine&rsquo;s floating point arithmetic; it must emulate
  81. the target&rsquo;s arithmetic. To ensure consistency, GCC always uses
  82. emulation to work with floating point values, even when the host and
  83. target floating point formats are identical.
  84. </p>
  85. <p>The following macros are provided by <samp>real.h</samp> for the compiler to
  86. use. All parts of the compiler which generate or optimize
  87. floating-point calculations must use these macros. They may evaluate
  88. their operands more than once, so operands must not have side effects.
  89. </p>
  90. <dl>
  91. <dt><a name="index-REAL_005fVALUE_005fTYPE"></a>Macro: <strong>REAL_VALUE_TYPE</strong></dt>
  92. <dd><p>The C data type to be used to hold a floating point value in the target
  93. machine&rsquo;s format. Typically this is a <code>struct</code> containing an
  94. array of <code>HOST_WIDE_INT</code>, but all code should treat it as an opaque
  95. quantity.
  96. </p></dd></dl>
  97. <dl>
  98. <dt><a name="index-REAL_005fVALUE_005fFIX"></a>Macro: <em>HOST_WIDE_INT</em> <strong>REAL_VALUE_FIX</strong> <em>(REAL_VALUE_TYPE <var>x</var>)</em></dt>
  99. <dd><p>Truncates <var>x</var> to a signed integer, rounding toward zero.
  100. </p></dd></dl>
  101. <dl>
  102. <dt><a name="index-REAL_005fVALUE_005fUNSIGNED_005fFIX"></a>Macro: <em>unsigned HOST_WIDE_INT</em> <strong>REAL_VALUE_UNSIGNED_FIX</strong> <em>(REAL_VALUE_TYPE <var>x</var>)</em></dt>
  103. <dd><p>Truncates <var>x</var> to an unsigned integer, rounding toward zero. If
  104. <var>x</var> is negative, returns zero.
  105. </p></dd></dl>
  106. <dl>
  107. <dt><a name="index-REAL_005fVALUE_005fATOF"></a>Macro: <em>REAL_VALUE_TYPE</em> <strong>REAL_VALUE_ATOF</strong> <em>(const char *<var>string</var>, machine_mode <var>mode</var>)</em></dt>
  108. <dd><p>Converts <var>string</var> into a floating point number in the target machine&rsquo;s
  109. representation for mode <var>mode</var>. This routine can handle both
  110. decimal and hexadecimal floating point constants, using the syntax
  111. defined by the C language for both.
  112. </p></dd></dl>
  113. <dl>
  114. <dt><a name="index-REAL_005fVALUE_005fNEGATIVE"></a>Macro: <em>int</em> <strong>REAL_VALUE_NEGATIVE</strong> <em>(REAL_VALUE_TYPE <var>x</var>)</em></dt>
  115. <dd><p>Returns 1 if <var>x</var> is negative (including negative zero), 0 otherwise.
  116. </p></dd></dl>
  117. <dl>
  118. <dt><a name="index-REAL_005fVALUE_005fISINF"></a>Macro: <em>int</em> <strong>REAL_VALUE_ISINF</strong> <em>(REAL_VALUE_TYPE <var>x</var>)</em></dt>
  119. <dd><p>Determines whether <var>x</var> represents infinity (positive or negative).
  120. </p></dd></dl>
  121. <dl>
  122. <dt><a name="index-REAL_005fVALUE_005fISNAN"></a>Macro: <em>int</em> <strong>REAL_VALUE_ISNAN</strong> <em>(REAL_VALUE_TYPE <var>x</var>)</em></dt>
  123. <dd><p>Determines whether <var>x</var> represents a &ldquo;NaN&rdquo; (not-a-number).
  124. </p></dd></dl>
  125. <dl>
  126. <dt><a name="index-REAL_005fVALUE_005fNEGATE"></a>Macro: <em>REAL_VALUE_TYPE</em> <strong>REAL_VALUE_NEGATE</strong> <em>(REAL_VALUE_TYPE <var>x</var>)</em></dt>
  127. <dd><p>Returns the negative of the floating point value <var>x</var>.
  128. </p></dd></dl>
  129. <dl>
  130. <dt><a name="index-REAL_005fVALUE_005fABS"></a>Macro: <em>REAL_VALUE_TYPE</em> <strong>REAL_VALUE_ABS</strong> <em>(REAL_VALUE_TYPE <var>x</var>)</em></dt>
  131. <dd><p>Returns the absolute value of <var>x</var>.
  132. </p></dd></dl>
  133. <hr>
  134. <div class="header">
  135. <p>
  136. Next: <a href="Mode-Switching.html#Mode-Switching" accesskey="n" rel="next">Mode Switching</a>, Previous: <a href="Debugging-Info.html#Debugging-Info" accesskey="p" rel="prev">Debugging Info</a>, Up: <a href="Target-Macros.html#Target-Macros" accesskey="u" rel="up">Target Macros</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  137. </div>
  138. </body>
  139. </html>