Decimal-Float.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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-2017 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 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>Using the GNU Compiler Collection (GCC): Decimal Float</title>
  20. <meta name="description" content="Using the GNU Compiler Collection (GCC): Decimal Float">
  21. <meta name="keywords" content="Using the GNU Compiler Collection (GCC): Decimal Float">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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="C-Extensions.html#C-Extensions" rel="up" title="C Extensions">
  30. <link href="Hex-Floats.html#Hex-Floats" rel="next" title="Hex Floats">
  31. <link href="Half_002dPrecision.html#Half_002dPrecision" rel="prev" title="Half-Precision">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Decimal-Float"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Hex-Floats.html#Hex-Floats" accesskey="n" rel="next">Hex Floats</a>, Previous: <a href="Half_002dPrecision.html#Half_002dPrecision" accesskey="p" rel="prev">Half-Precision</a>, Up: <a href="C-Extensions.html#C-Extensions" accesskey="u" rel="up">C Extensions</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>
  66. </div>
  67. <hr>
  68. <a name="Decimal-Floating-Types"></a>
  69. <h3 class="section">6.13 Decimal Floating Types</h3>
  70. <a name="index-decimal-floating-types"></a>
  71. <a name="index-_005fDecimal32-data-type"></a>
  72. <a name="index-_005fDecimal64-data-type"></a>
  73. <a name="index-_005fDecimal128-data-type"></a>
  74. <a name="index-df-integer-suffix"></a>
  75. <a name="index-dd-integer-suffix"></a>
  76. <a name="index-dl-integer-suffix"></a>
  77. <a name="index-DF-integer-suffix"></a>
  78. <a name="index-DD-integer-suffix"></a>
  79. <a name="index-DL-integer-suffix"></a>
  80. <p>As an extension, GNU C supports decimal floating types as
  81. defined in the N1312 draft of ISO/IEC WDTR24732. Support for decimal
  82. floating types in GCC will evolve as the draft technical report changes.
  83. Calling conventions for any target might also change. Not all targets
  84. support decimal floating types.
  85. </p>
  86. <p>The decimal floating types are <code>_Decimal32</code>, <code>_Decimal64</code>, and
  87. <code>_Decimal128</code>. They use a radix of ten, unlike the floating types
  88. <code>float</code>, <code>double</code>, and <code>long double</code> whose radix is not
  89. specified by the C standard but is usually two.
  90. </p>
  91. <p>Support for decimal floating types includes the arithmetic operators
  92. add, subtract, multiply, divide; unary arithmetic operators;
  93. relational operators; equality operators; and conversions to and from
  94. integer and other floating types. Use a suffix &lsquo;<samp>df</samp>&rsquo; or
  95. &lsquo;<samp>DF</samp>&rsquo; in a literal constant of type <code>_Decimal32</code>, &lsquo;<samp>dd</samp>&rsquo;
  96. or &lsquo;<samp>DD</samp>&rsquo; for <code>_Decimal64</code>, and &lsquo;<samp>dl</samp>&rsquo; or &lsquo;<samp>DL</samp>&rsquo; for
  97. <code>_Decimal128</code>.
  98. </p>
  99. <p>GCC support of decimal float as specified by the draft technical report
  100. is incomplete:
  101. </p>
  102. <ul>
  103. <li> When the value of a decimal floating type cannot be represented in the
  104. integer type to which it is being converted, the result is undefined
  105. rather than the result value specified by the draft technical report.
  106. </li><li> GCC does not provide the C library functionality associated with
  107. <samp>math.h</samp>, <samp>fenv.h</samp>, <samp>stdio.h</samp>, <samp>stdlib.h</samp>, and
  108. <samp>wchar.h</samp>, which must come from a separate C library implementation.
  109. Because of this the GNU C compiler does not define macro
  110. <code>__STDC_DEC_FP__</code> to indicate that the implementation conforms to
  111. the technical report.
  112. </li></ul>
  113. <p>Types <code>_Decimal32</code>, <code>_Decimal64</code>, and <code>_Decimal128</code>
  114. are supported by the DWARF debug information format.
  115. </p>
  116. <hr>
  117. <div class="header">
  118. <p>
  119. Next: <a href="Hex-Floats.html#Hex-Floats" accesskey="n" rel="next">Hex Floats</a>, Previous: <a href="Half_002dPrecision.html#Half_002dPrecision" accesskey="p" rel="prev">Half-Precision</a>, Up: <a href="C-Extensions.html#C-Extensions" accesskey="u" rel="up">C Extensions</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>
  120. </div>
  121. </body>
  122. </html>