• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/gcc/
1<html lang="en">
2<head>
3<title>Fixed-Point - Using the GNU Compiler Collection (GCC)</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Using the GNU Compiler Collection (GCC)">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="C-Extensions.html#C-Extensions" title="C Extensions">
9<link rel="prev" href="Hex-Floats.html#Hex-Floats" title="Hex Floats">
10<link rel="next" href="Named-Address-Spaces.html#Named-Address-Spaces" title="Named Address Spaces">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
152010 Free Software Foundation, Inc.
16
17Permission is granted to copy, distribute and/or modify this document
18under the terms of the GNU Free Documentation License, Version 1.3 or
19any later version published by the Free Software Foundation; with the
20Invariant Sections being ``Funding Free Software'', the Front-Cover
21Texts being (a) (see below), and with the Back-Cover Texts being (b)
22(see below).  A copy of the license is included in the section entitled
23``GNU Free Documentation License''.
24
25(a) The FSF's Front-Cover Text is:
26
27     A GNU Manual
28
29(b) The FSF's Back-Cover Text is:
30
31     You have freedom to copy and modify this GNU Manual, like GNU
32     software.  Copies published by the Free Software Foundation raise
33     funds for GNU development.-->
34<meta http-equiv="Content-Style-Type" content="text/css">
35<style type="text/css"><!--
36  pre.display { font-family:inherit }
37  pre.format  { font-family:inherit }
38  pre.smalldisplay { font-family:inherit; font-size:smaller }
39  pre.smallformat  { font-family:inherit; font-size:smaller }
40  pre.smallexample { font-size:smaller }
41  pre.smalllisp    { font-size:smaller }
42  span.sc    { font-variant:small-caps }
43  span.roman { font-family:serif; font-weight:normal; } 
44  span.sansserif { font-family:sans-serif; font-weight:normal; } 
45--></style>
46<link rel="stylesheet" type="text/css" href="../cs.css">
47</head>
48<body>
49<div class="node">
50<a name="Fixed-Point"></a>
51<a name="Fixed_002dPoint"></a>
52<p>
53Next:&nbsp;<a rel="next" accesskey="n" href="Named-Address-Spaces.html#Named-Address-Spaces">Named Address Spaces</a>,
54Previous:&nbsp;<a rel="previous" accesskey="p" href="Hex-Floats.html#Hex-Floats">Hex Floats</a>,
55Up:&nbsp;<a rel="up" accesskey="u" href="C-Extensions.html#C-Extensions">C Extensions</a>
56<hr>
57</div>
58
59<h3 class="section">6.15 Fixed-Point Types</h3>
60
61<p><a name="index-fixed_002dpoint-types-2307"></a><a name="index-g_t_0040code_007b_005fFract_007d-data-type-2308"></a><a name="index-g_t_0040code_007b_005fAccum_007d-data-type-2309"></a><a name="index-g_t_0040code_007b_005fSat_007d-data-type-2310"></a><a name="index-g_t_0040code_007bhr_007d-fixed_002dsuffix-2311"></a><a name="index-g_t_0040code_007br_007d-fixed_002dsuffix-2312"></a><a name="index-g_t_0040code_007blr_007d-fixed_002dsuffix-2313"></a><a name="index-g_t_0040code_007bllr_007d-fixed_002dsuffix-2314"></a><a name="index-g_t_0040code_007buhr_007d-fixed_002dsuffix-2315"></a><a name="index-g_t_0040code_007bur_007d-fixed_002dsuffix-2316"></a><a name="index-g_t_0040code_007bulr_007d-fixed_002dsuffix-2317"></a><a name="index-g_t_0040code_007bullr_007d-fixed_002dsuffix-2318"></a><a name="index-g_t_0040code_007bhk_007d-fixed_002dsuffix-2319"></a><a name="index-g_t_0040code_007bk_007d-fixed_002dsuffix-2320"></a><a name="index-g_t_0040code_007blk_007d-fixed_002dsuffix-2321"></a><a name="index-g_t_0040code_007bllk_007d-fixed_002dsuffix-2322"></a><a name="index-g_t_0040code_007buhk_007d-fixed_002dsuffix-2323"></a><a name="index-g_t_0040code_007buk_007d-fixed_002dsuffix-2324"></a><a name="index-g_t_0040code_007bulk_007d-fixed_002dsuffix-2325"></a><a name="index-g_t_0040code_007bullk_007d-fixed_002dsuffix-2326"></a><a name="index-g_t_0040code_007bHR_007d-fixed_002dsuffix-2327"></a><a name="index-g_t_0040code_007bR_007d-fixed_002dsuffix-2328"></a><a name="index-g_t_0040code_007bLR_007d-fixed_002dsuffix-2329"></a><a name="index-g_t_0040code_007bLLR_007d-fixed_002dsuffix-2330"></a><a name="index-g_t_0040code_007bUHR_007d-fixed_002dsuffix-2331"></a><a name="index-g_t_0040code_007bUR_007d-fixed_002dsuffix-2332"></a><a name="index-g_t_0040code_007bULR_007d-fixed_002dsuffix-2333"></a><a name="index-g_t_0040code_007bULLR_007d-fixed_002dsuffix-2334"></a><a name="index-g_t_0040code_007bHK_007d-fixed_002dsuffix-2335"></a><a name="index-g_t_0040code_007bK_007d-fixed_002dsuffix-2336"></a><a name="index-g_t_0040code_007bLK_007d-fixed_002dsuffix-2337"></a><a name="index-g_t_0040code_007bLLK_007d-fixed_002dsuffix-2338"></a><a name="index-g_t_0040code_007bUHK_007d-fixed_002dsuffix-2339"></a><a name="index-g_t_0040code_007bUK_007d-fixed_002dsuffix-2340"></a><a name="index-g_t_0040code_007bULK_007d-fixed_002dsuffix-2341"></a><a name="index-g_t_0040code_007bULLK_007d-fixed_002dsuffix-2342"></a>
62As an extension, the GNU C compiler supports fixed-point types as
63defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
64types in GCC will evolve as the draft technical report changes. 
65Calling conventions for any target might also change.  Not all targets
66support fixed-point types.
67
68 <p>The fixed-point types are
69<code>short _Fract</code>,
70<code>_Fract</code>,
71<code>long _Fract</code>,
72<code>long long _Fract</code>,
73<code>unsigned short _Fract</code>,
74<code>unsigned _Fract</code>,
75<code>unsigned long _Fract</code>,
76<code>unsigned long long _Fract</code>,
77<code>_Sat short _Fract</code>,
78<code>_Sat _Fract</code>,
79<code>_Sat long _Fract</code>,
80<code>_Sat long long _Fract</code>,
81<code>_Sat unsigned short _Fract</code>,
82<code>_Sat unsigned _Fract</code>,
83<code>_Sat unsigned long _Fract</code>,
84<code>_Sat unsigned long long _Fract</code>,
85<code>short _Accum</code>,
86<code>_Accum</code>,
87<code>long _Accum</code>,
88<code>long long _Accum</code>,
89<code>unsigned short _Accum</code>,
90<code>unsigned _Accum</code>,
91<code>unsigned long _Accum</code>,
92<code>unsigned long long _Accum</code>,
93<code>_Sat short _Accum</code>,
94<code>_Sat _Accum</code>,
95<code>_Sat long _Accum</code>,
96<code>_Sat long long _Accum</code>,
97<code>_Sat unsigned short _Accum</code>,
98<code>_Sat unsigned _Accum</code>,
99<code>_Sat unsigned long _Accum</code>,
100<code>_Sat unsigned long long _Accum</code>.
101
102 <p>Fixed-point data values contain fractional and optional integral parts. 
103The format of fixed-point data varies and depends on the target machine.
104
105 <p>Support for fixed-point types includes:
106     <ul>
107<li>prefix and postfix increment and decrement operators (<code>++</code>, <code>--</code>)
108<li>unary arithmetic operators (<code>+</code>, <code>-</code>, <code>!</code>)
109<li>binary arithmetic operators (<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>)
110<li>binary shift operators (<code>&lt;&lt;</code>, <code>&gt;&gt;</code>)
111<li>relational operators (<code>&lt;</code>, <code>&lt;=</code>, <code>&gt;=</code>, <code>&gt;</code>)
112<li>equality operators (<code>==</code>, <code>!=</code>)
113<li>assignment operators (<code>+=</code>, <code>-=</code>, <code>*=</code>, <code>/=</code>,
114<code>&lt;&lt;=</code>, <code>&gt;&gt;=</code>)
115<li>conversions to and from integer, floating-point, or fixed-point types
116</ul>
117
118 <p>Use a suffix in a fixed-point literal constant:
119     <ul>
120<li>&lsquo;<samp><span class="samp">hr</span></samp>&rsquo; or &lsquo;<samp><span class="samp">HR</span></samp>&rsquo; for <code>short _Fract</code> and
121<code>_Sat short _Fract</code>
122<li>&lsquo;<samp><span class="samp">r</span></samp>&rsquo; or &lsquo;<samp><span class="samp">R</span></samp>&rsquo; for <code>_Fract</code> and <code>_Sat _Fract</code>
123<li>&lsquo;<samp><span class="samp">lr</span></samp>&rsquo; or &lsquo;<samp><span class="samp">LR</span></samp>&rsquo; for <code>long _Fract</code> and
124<code>_Sat long _Fract</code>
125<li>&lsquo;<samp><span class="samp">llr</span></samp>&rsquo; or &lsquo;<samp><span class="samp">LLR</span></samp>&rsquo; for <code>long long _Fract</code> and
126<code>_Sat long long _Fract</code>
127<li>&lsquo;<samp><span class="samp">uhr</span></samp>&rsquo; or &lsquo;<samp><span class="samp">UHR</span></samp>&rsquo; for <code>unsigned short _Fract</code> and
128<code>_Sat unsigned short _Fract</code>
129<li>&lsquo;<samp><span class="samp">ur</span></samp>&rsquo; or &lsquo;<samp><span class="samp">UR</span></samp>&rsquo; for <code>unsigned _Fract</code> and
130<code>_Sat unsigned _Fract</code>
131<li>&lsquo;<samp><span class="samp">ulr</span></samp>&rsquo; or &lsquo;<samp><span class="samp">ULR</span></samp>&rsquo; for <code>unsigned long _Fract</code> and
132<code>_Sat unsigned long _Fract</code>
133<li>&lsquo;<samp><span class="samp">ullr</span></samp>&rsquo; or &lsquo;<samp><span class="samp">ULLR</span></samp>&rsquo; for <code>unsigned long long _Fract</code>
134and <code>_Sat unsigned long long _Fract</code>
135<li>&lsquo;<samp><span class="samp">hk</span></samp>&rsquo; or &lsquo;<samp><span class="samp">HK</span></samp>&rsquo; for <code>short _Accum</code> and
136<code>_Sat short _Accum</code>
137<li>&lsquo;<samp><span class="samp">k</span></samp>&rsquo; or &lsquo;<samp><span class="samp">K</span></samp>&rsquo; for <code>_Accum</code> and <code>_Sat _Accum</code>
138<li>&lsquo;<samp><span class="samp">lk</span></samp>&rsquo; or &lsquo;<samp><span class="samp">LK</span></samp>&rsquo; for <code>long _Accum</code> and
139<code>_Sat long _Accum</code>
140<li>&lsquo;<samp><span class="samp">llk</span></samp>&rsquo; or &lsquo;<samp><span class="samp">LLK</span></samp>&rsquo; for <code>long long _Accum</code> and
141<code>_Sat long long _Accum</code>
142<li>&lsquo;<samp><span class="samp">uhk</span></samp>&rsquo; or &lsquo;<samp><span class="samp">UHK</span></samp>&rsquo; for <code>unsigned short _Accum</code> and
143<code>_Sat unsigned short _Accum</code>
144<li>&lsquo;<samp><span class="samp">uk</span></samp>&rsquo; or &lsquo;<samp><span class="samp">UK</span></samp>&rsquo; for <code>unsigned _Accum</code> and
145<code>_Sat unsigned _Accum</code>
146<li>&lsquo;<samp><span class="samp">ulk</span></samp>&rsquo; or &lsquo;<samp><span class="samp">ULK</span></samp>&rsquo; for <code>unsigned long _Accum</code> and
147<code>_Sat unsigned long _Accum</code>
148<li>&lsquo;<samp><span class="samp">ullk</span></samp>&rsquo; or &lsquo;<samp><span class="samp">ULLK</span></samp>&rsquo; for <code>unsigned long long _Accum</code>
149and <code>_Sat unsigned long long _Accum</code>
150</ul>
151
152 <p>GCC support of fixed-point types as specified by the draft technical report
153is incomplete:
154
155     <ul>
156<li>Pragmas to control overflow and rounding behaviors are not implemented. 
157</ul>
158
159 <p>Fixed-point types are supported by the DWARF2 debug information format.
160
161 </body></html>
162
163