|
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
-
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3 or
- any later version published by the Free Software Foundation; with the
- Invariant Sections being "Funding Free Software", the Front-Cover
- Texts being (a) (see below), and with the Back-Cover Texts being (b)
- (see below). A copy of the license is included in the section entitled
- "GNU Free Documentation License".
-
- (a) The FSF's Front-Cover Text is:
-
- A GNU Manual
-
- (b) The FSF's Back-Cover Text is:
-
- You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development. -->
- <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Fixed-Point (Using the GNU Compiler Collection (GCC))</title>
-
- <meta name="description" content="Fixed-Point (Using the GNU Compiler Collection (GCC))">
- <meta name="keywords" content="Fixed-Point (Using the GNU Compiler Collection (GCC))">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="makeinfo">
- <link href="index.html#Top" rel="start" title="Top">
- <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
- <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
- <link href="C-Extensions.html#C-Extensions" rel="up" title="C Extensions">
- <link href="Named-Address-Spaces.html#Named-Address-Spaces" rel="next" title="Named Address Spaces">
- <link href="Hex-Floats.html#Hex-Floats" rel="prev" title="Hex Floats">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.indentedblock {margin-right: 0em}
- blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
- blockquote.smallquotation {font-size: smaller}
- div.display {margin-left: 3.2em}
- div.example {margin-left: 3.2em}
- div.lisp {margin-left: 3.2em}
- div.smalldisplay {margin-left: 3.2em}
- div.smallexample {margin-left: 3.2em}
- div.smalllisp {margin-left: 3.2em}
- kbd {font-style: oblique}
- pre.display {font-family: inherit}
- pre.format {font-family: inherit}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: inherit; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: inherit; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.nolinebreak {white-space: nowrap}
- span.roman {font-family: initial; font-weight: normal}
- span.sansserif {font-family: sans-serif; font-weight: normal}
- ul.no-bullet {list-style: none}
- -->
- </style>
-
-
- </head>
-
- <body lang="en">
- <a name="Fixed_002dPoint"></a>
- <div class="header">
- <p>
- Next: <a href="Named-Address-Spaces.html#Named-Address-Spaces" accesskey="n" rel="next">Named Address Spaces</a>, Previous: <a href="Hex-Floats.html#Hex-Floats" accesskey="p" rel="prev">Hex Floats</a>, Up: <a href="C-Extensions.html#C-Extensions" accesskey="u" rel="up">C Extensions</a> [<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>
- </div>
- <hr>
- <a name="Fixed_002dPoint-Types"></a>
- <h3 class="section">6.16 Fixed-Point Types</h3>
- <a name="index-fixed_002dpoint-types"></a>
- <a name="index-_005fFract-data-type"></a>
- <a name="index-_005fAccum-data-type"></a>
- <a name="index-_005fSat-data-type"></a>
- <a name="index-hr-fixed_002dsuffix"></a>
- <a name="index-r-fixed_002dsuffix"></a>
- <a name="index-lr-fixed_002dsuffix"></a>
- <a name="index-llr-fixed_002dsuffix"></a>
- <a name="index-uhr-fixed_002dsuffix"></a>
- <a name="index-ur-fixed_002dsuffix"></a>
- <a name="index-ulr-fixed_002dsuffix"></a>
- <a name="index-ullr-fixed_002dsuffix"></a>
- <a name="index-hk-fixed_002dsuffix"></a>
- <a name="index-k-fixed_002dsuffix"></a>
- <a name="index-lk-fixed_002dsuffix"></a>
- <a name="index-llk-fixed_002dsuffix"></a>
- <a name="index-uhk-fixed_002dsuffix"></a>
- <a name="index-uk-fixed_002dsuffix"></a>
- <a name="index-ulk-fixed_002dsuffix"></a>
- <a name="index-ullk-fixed_002dsuffix"></a>
- <a name="index-HR-fixed_002dsuffix"></a>
- <a name="index-R-fixed_002dsuffix"></a>
- <a name="index-LR-fixed_002dsuffix"></a>
- <a name="index-LLR-fixed_002dsuffix"></a>
- <a name="index-UHR-fixed_002dsuffix"></a>
- <a name="index-UR-fixed_002dsuffix"></a>
- <a name="index-ULR-fixed_002dsuffix"></a>
- <a name="index-ULLR-fixed_002dsuffix"></a>
- <a name="index-HK-fixed_002dsuffix"></a>
- <a name="index-K-fixed_002dsuffix"></a>
- <a name="index-LK-fixed_002dsuffix"></a>
- <a name="index-LLK-fixed_002dsuffix"></a>
- <a name="index-UHK-fixed_002dsuffix"></a>
- <a name="index-UK-fixed_002dsuffix"></a>
- <a name="index-ULK-fixed_002dsuffix"></a>
- <a name="index-ULLK-fixed_002dsuffix"></a>
-
- <p>As an extension, GNU C supports fixed-point types as
- defined in the N1169 draft of ISO/IEC DTR 18037. Support for fixed-point
- types in GCC will evolve as the draft technical report changes.
- Calling conventions for any target might also change. Not all targets
- support fixed-point types.
- </p>
- <p>The fixed-point types are
- <code>short _Fract</code>,
- <code>_Fract</code>,
- <code>long _Fract</code>,
- <code>long long _Fract</code>,
- <code>unsigned short _Fract</code>,
- <code>unsigned _Fract</code>,
- <code>unsigned long _Fract</code>,
- <code>unsigned long long _Fract</code>,
- <code>_Sat short _Fract</code>,
- <code>_Sat _Fract</code>,
- <code>_Sat long _Fract</code>,
- <code>_Sat long long _Fract</code>,
- <code>_Sat unsigned short _Fract</code>,
- <code>_Sat unsigned _Fract</code>,
- <code>_Sat unsigned long _Fract</code>,
- <code>_Sat unsigned long long _Fract</code>,
- <code>short _Accum</code>,
- <code>_Accum</code>,
- <code>long _Accum</code>,
- <code>long long _Accum</code>,
- <code>unsigned short _Accum</code>,
- <code>unsigned _Accum</code>,
- <code>unsigned long _Accum</code>,
- <code>unsigned long long _Accum</code>,
- <code>_Sat short _Accum</code>,
- <code>_Sat _Accum</code>,
- <code>_Sat long _Accum</code>,
- <code>_Sat long long _Accum</code>,
- <code>_Sat unsigned short _Accum</code>,
- <code>_Sat unsigned _Accum</code>,
- <code>_Sat unsigned long _Accum</code>,
- <code>_Sat unsigned long long _Accum</code>.
- </p>
- <p>Fixed-point data values contain fractional and optional integral parts.
- The format of fixed-point data varies and depends on the target machine.
- </p>
- <p>Support for fixed-point types includes:
- </p><ul>
- <li> prefix and postfix increment and decrement operators (<code>++</code>, <code>--</code>)
- </li><li> unary arithmetic operators (<code>+</code>, <code>-</code>, <code>!</code>)
- </li><li> binary arithmetic operators (<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>)
- </li><li> binary shift operators (<code><<</code>, <code>>></code>)
- </li><li> relational operators (<code><</code>, <code><=</code>, <code>>=</code>, <code>></code>)
- </li><li> equality operators (<code>==</code>, <code>!=</code>)
- </li><li> assignment operators (<code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>,
- <code><<=</code>, <code>>>=</code>)
- </li><li> conversions to and from integer, floating-point, or fixed-point types
- </li></ul>
-
- <p>Use a suffix in a fixed-point literal constant:
- </p><ul>
- <li> ‘<samp>hr</samp>’ or ‘<samp>HR</samp>’ for <code>short _Fract</code> and
- <code>_Sat short _Fract</code>
- </li><li> ‘<samp>r</samp>’ or ‘<samp>R</samp>’ for <code>_Fract</code> and <code>_Sat _Fract</code>
- </li><li> ‘<samp>lr</samp>’ or ‘<samp>LR</samp>’ for <code>long _Fract</code> and
- <code>_Sat long _Fract</code>
- </li><li> ‘<samp>llr</samp>’ or ‘<samp>LLR</samp>’ for <code>long long _Fract</code> and
- <code>_Sat long long _Fract</code>
- </li><li> ‘<samp>uhr</samp>’ or ‘<samp>UHR</samp>’ for <code>unsigned short _Fract</code> and
- <code>_Sat unsigned short _Fract</code>
- </li><li> ‘<samp>ur</samp>’ or ‘<samp>UR</samp>’ for <code>unsigned _Fract</code> and
- <code>_Sat unsigned _Fract</code>
- </li><li> ‘<samp>ulr</samp>’ or ‘<samp>ULR</samp>’ for <code>unsigned long _Fract</code> and
- <code>_Sat unsigned long _Fract</code>
- </li><li> ‘<samp>ullr</samp>’ or ‘<samp>ULLR</samp>’ for <code>unsigned long long _Fract</code>
- and <code>_Sat unsigned long long _Fract</code>
- </li><li> ‘<samp>hk</samp>’ or ‘<samp>HK</samp>’ for <code>short _Accum</code> and
- <code>_Sat short _Accum</code>
- </li><li> ‘<samp>k</samp>’ or ‘<samp>K</samp>’ for <code>_Accum</code> and <code>_Sat _Accum</code>
- </li><li> ‘<samp>lk</samp>’ or ‘<samp>LK</samp>’ for <code>long _Accum</code> and
- <code>_Sat long _Accum</code>
- </li><li> ‘<samp>llk</samp>’ or ‘<samp>LLK</samp>’ for <code>long long _Accum</code> and
- <code>_Sat long long _Accum</code>
- </li><li> ‘<samp>uhk</samp>’ or ‘<samp>UHK</samp>’ for <code>unsigned short _Accum</code> and
- <code>_Sat unsigned short _Accum</code>
- </li><li> ‘<samp>uk</samp>’ or ‘<samp>UK</samp>’ for <code>unsigned _Accum</code> and
- <code>_Sat unsigned _Accum</code>
- </li><li> ‘<samp>ulk</samp>’ or ‘<samp>ULK</samp>’ for <code>unsigned long _Accum</code> and
- <code>_Sat unsigned long _Accum</code>
- </li><li> ‘<samp>ullk</samp>’ or ‘<samp>ULLK</samp>’ for <code>unsigned long long _Accum</code>
- and <code>_Sat unsigned long long _Accum</code>
- </li></ul>
-
- <p>GCC support of fixed-point types as specified by the draft technical report
- is incomplete:
- </p>
- <ul>
- <li> Pragmas to control overflow and rounding behaviors are not implemented.
- </li></ul>
-
- <p>Fixed-point types are supported by the DWARF debug information format.
- </p>
- <hr>
- <div class="header">
- <p>
- Next: <a href="Named-Address-Spaces.html#Named-Address-Spaces" accesskey="n" rel="next">Named Address Spaces</a>, Previous: <a href="Hex-Floats.html#Hex-Floats" accesskey="p" rel="prev">Hex Floats</a>, Up: <a href="C-Extensions.html#C-Extensions" accesskey="u" rel="up">C Extensions</a> [<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>
- </div>
-
-
-
- </body>
- </html>
|