toolchain/gcc-linaro-6.3.1-2017.02-x8.../share/doc/gcc/Fixed_002dPoint.html

225 lines
10 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2016 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 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Using the GNU Compiler Collection (GCC): Fixed-Point</title>
<meta name="description" content="Using the GNU Compiler Collection (GCC): Fixed-Point">
<meta name="keywords" content="Using the GNU Compiler Collection (GCC): Fixed-Point">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
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.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<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> &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>
</div>
<hr>
<a name="Fixed_002dPoint-Types"></a>
<h3 class="section">6.15 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>&lt;&lt;</code>, <code>&gt;&gt;</code>)
</li><li> relational operators (<code>&lt;</code>, <code>&lt;=</code>, <code>&gt;=</code>, <code>&gt;</code>)
</li><li> equality operators (<code>==</code>, <code>!=</code>)
</li><li> assignment operators (<code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>,
<code>&lt;&lt;=</code>, <code>&gt;&gt;=</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> &lsquo;<samp>hr</samp>&rsquo; or &lsquo;<samp>HR</samp>&rsquo; for <code>short _Fract</code> and
<code>_Sat short _Fract</code>
</li><li> &lsquo;<samp>r</samp>&rsquo; or &lsquo;<samp>R</samp>&rsquo; for <code>_Fract</code> and <code>_Sat _Fract</code>
</li><li> &lsquo;<samp>lr</samp>&rsquo; or &lsquo;<samp>LR</samp>&rsquo; for <code>long _Fract</code> and
<code>_Sat long _Fract</code>
</li><li> &lsquo;<samp>llr</samp>&rsquo; or &lsquo;<samp>LLR</samp>&rsquo; for <code>long long _Fract</code> and
<code>_Sat long long _Fract</code>
</li><li> &lsquo;<samp>uhr</samp>&rsquo; or &lsquo;<samp>UHR</samp>&rsquo; for <code>unsigned short _Fract</code> and
<code>_Sat unsigned short _Fract</code>
</li><li> &lsquo;<samp>ur</samp>&rsquo; or &lsquo;<samp>UR</samp>&rsquo; for <code>unsigned _Fract</code> and
<code>_Sat unsigned _Fract</code>
</li><li> &lsquo;<samp>ulr</samp>&rsquo; or &lsquo;<samp>ULR</samp>&rsquo; for <code>unsigned long _Fract</code> and
<code>_Sat unsigned long _Fract</code>
</li><li> &lsquo;<samp>ullr</samp>&rsquo; or &lsquo;<samp>ULLR</samp>&rsquo; for <code>unsigned long long _Fract</code>
and <code>_Sat unsigned long long _Fract</code>
</li><li> &lsquo;<samp>hk</samp>&rsquo; or &lsquo;<samp>HK</samp>&rsquo; for <code>short _Accum</code> and
<code>_Sat short _Accum</code>
</li><li> &lsquo;<samp>k</samp>&rsquo; or &lsquo;<samp>K</samp>&rsquo; for <code>_Accum</code> and <code>_Sat _Accum</code>
</li><li> &lsquo;<samp>lk</samp>&rsquo; or &lsquo;<samp>LK</samp>&rsquo; for <code>long _Accum</code> and
<code>_Sat long _Accum</code>
</li><li> &lsquo;<samp>llk</samp>&rsquo; or &lsquo;<samp>LLK</samp>&rsquo; for <code>long long _Accum</code> and
<code>_Sat long long _Accum</code>
</li><li> &lsquo;<samp>uhk</samp>&rsquo; or &lsquo;<samp>UHK</samp>&rsquo; for <code>unsigned short _Accum</code> and
<code>_Sat unsigned short _Accum</code>
</li><li> &lsquo;<samp>uk</samp>&rsquo; or &lsquo;<samp>UK</samp>&rsquo; for <code>unsigned _Accum</code> and
<code>_Sat unsigned _Accum</code>
</li><li> &lsquo;<samp>ulk</samp>&rsquo; or &lsquo;<samp>ULK</samp>&rsquo; for <code>unsigned long _Accum</code> and
<code>_Sat unsigned long _Accum</code>
</li><li> &lsquo;<samp>ullk</samp>&rsquo; or &lsquo;<samp>ULLK</samp>&rsquo; 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> &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>
</div>
</body>
</html>