<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>3.10. Fixed-Point Arithmetic</title><link rel="stylesheet" href="cs.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><link rel="home" href="index.html" title="Sourcery G++ Lite"><link rel="up" href="chap-target.html" title="Chapter 3. Sourcery G++ Lite for ARM GNU/Linux"><link rel="prev" href="sec-armfloat.html" title="3.9. Using VFP Floating Point"><link rel="next" href="ch03s11.html" title="3.11. ABI Compatibility"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">3.10. Fixed-Point Arithmetic</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-armfloat.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Sourcery G++ Lite for ARM GNU/Linux</th><td width="20%" align="right"> <a accesskey="n" href="ch03s11.html">Next</a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="sec-arm-fixed-point"></a>3.10. Fixed-Point Arithmetic</h2></div></div></div><p> | |
Sourcery G++ for ARM GNU/Linux includes experimental support for | |
fixed-point arithmetic using a set of new data types, as described in the | |
draft ISO/IEC technical report TR 18037. This support is provided for all | |
ARM targets, and uses specialized instructions where available, e.g. | |
saturating add and subtract operations on ARMv6T2 and above. Library | |
functions are used for operations which are not natively supported on | |
the target architecture. | |
</p><p> | |
This feature is a GNU extension, so is only available when the selected | |
language standard includes GNU extensions (e.g. | |
<code class="option">-std=gnu90</code>, which is the default). Furthermore, only C is | |
supported, not C++. | |
</p><p> | |
TR 18037 leaves up to the implementation the sizes of various quantities | |
within the new data types it defines. For Sourcery G++ for ARM GNU/Linux, | |
these are, briefly: | |
</p><div class="itemizedlist"><ul type="disc"><li><code class="type">short _Fract</code>: One sign bit, 7 fractional bits</li><li><code class="type">_Fract</code>: One sign bit, 15 fractional bits</li><li><code class="type">long _Fract</code>: One sign bit, 31 fractional bits</li><li><code class="type">unsigned short _Fract</code>: 8 fractional bits</li><li><code class="type">unsigned _Fract</code>: 16 fractional bits</li><li><code class="type">unsigned long _Fract</code>: 32 fractional bits</li><li><code class="type">short _Accum</code>: One sign bit, 7 fractional bits, 8 integral bits</li><li><code class="type">_Accum</code>: One sign bit, 15 fractional bits, 16 integral bits</li><li><code class="type">long _Accum</code>: One sign bit, 31 fractional bits, 32 integral bits</li><li><code class="type">unsigned short _Accum</code>: 8 fractional bits, 8 integral bits</li><li><code class="type">unsigned _Accum</code>: 16 fractional bits, 16 integral bits</li><li><code class="type">unsigned long _Accum</code>: 32 fractional bits, 32 integral bits</li></ul></div><p> | |
</p><p> | |
These values (and various other useful constants) are also defined | |
in the header file <code class="filename">stdfix.h</code> | |
for use in your programs. Note that there is currently no support | |
for the new standard-library functions described in TR 18037, nor | |
for the pragmas controlling precision of operations. | |
</p><p> | |
Fixed-point extensions are not currently supported by GDB, nor are | |
they compliant with the ARM EABI (which does not specify anything | |
about fixed-point types at present). Code using fixed-point types | |
cannot be expected to interact properly (across ABI boundaries) | |
with code generated by other compilers for the ARM architecture. | |
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-armfloat.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="chap-target.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s11.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">3.9. Using VFP Floating Point </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 3.11. ABI Compatibility</td></tr></table></div></body></html> |