summaryrefslogtreecommitdiff
path: root/static/freebsd/man3/Q_QADDI.3 3.html
blob: 67faa1cf137d21706c66ce43f16b0abf7a5c5b50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<table class="head">
  <tr>
    <td class="head-ltitle">Q_QADDI(3)</td>
    <td class="head-vol">Library Functions Manual</td>
    <td class="head-rtitle">Q_QADDI(3)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">Q_QADDI</code>, <code class="Nm">Q_QDIVI</code>,
    <code class="Nm">Q_QMULI</code>, <code class="Nm">Q_QSUBI</code>,
    <code class="Nm">Q_QFRACI</code>, <code class="Nm">Q_QCPYVALI</code>
    &#x2014; <span class="Nd">fixed-point math functions which apply integers to
    a Q number</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
    &lt;<a class="In">sys/qmath.h</a>&gt;</code></p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">Q_QADDI</code>(<var class="Fa" style="white-space: nowrap;">QTYPE
    *a</var>, <var class="Fa" style="white-space: nowrap;">ITYPE b</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">Q_QDIVI</code>(<var class="Fa" style="white-space: nowrap;">QTYPE
    *a</var>, <var class="Fa" style="white-space: nowrap;">ITYPE b</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">Q_QMULI</code>(<var class="Fa" style="white-space: nowrap;">QTYPE
    *a</var>, <var class="Fa" style="white-space: nowrap;">ITYPE b</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">Q_QSUBI</code>(<var class="Fa" style="white-space: nowrap;">QTYPE
    *a</var>, <var class="Fa" style="white-space: nowrap;">ITYPE b</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">Q_QFRACI</code>(<var class="Fa" style="white-space: nowrap;">QTYPE
    *q</var>, <var class="Fa" style="white-space: nowrap;">ITYPE n</var>,
    <var class="Fa" style="white-space: nowrap;">ITYPE d</var>);</p>
<p class="Pp"><var class="Ft">int</var>
  <br/>
  <code class="Fn">Q_QCPYVALI</code>(<var class="Fa" style="white-space: nowrap;">QTYPE
    *q</var>, <var class="Fa" style="white-space: nowrap;">ITYPE i</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">The
    <a class="permalink" href="#Q_QADDI"><code class="Fn" id="Q_QADDI">Q_QADDI</code></a>(),
    <a class="permalink" href="#Q_QDIVI"><code class="Fn" id="Q_QDIVI">Q_QDIVI</code></a>(),
    <a class="permalink" href="#Q_QMULI"><code class="Fn" id="Q_QMULI">Q_QMULI</code></a>()
    and
    <a class="permalink" href="#Q_QSUBI"><code class="Fn" id="Q_QSUBI">Q_QSUBI</code></a>()
    functions add, divide, multiply or subtract <var class="Fa">b</var>
    to/by/from <var class="Fa">a</var> respectively, storing the result in
    <var class="Fa">a</var>.</p>
<p class="Pp" id="Q_QFRACI">The
    <a class="permalink" href="#Q_QFRACI"><code class="Fn">Q_QFRACI</code></a>()
    function computes the fraction <var class="Fa">n</var> divided by
    <var class="Fa">d</var> and stores the fixed-point result in
    <var class="Fa">q</var>.</p>
<p class="Pp" id="Q_QCPYVALI">The
    <a class="permalink" href="#Q_QCPYVALI"><code class="Fn">Q_QCPYVALI</code></a>()
    function overwrites <var class="Fa">q</var>'s integer and fractional bits
    with the Q representation of integer value <var class="Fa">i</var>.</p>
<p class="Pp">All of those functions operate on the following data types:
    <var class="Vt">s8q_t</var>, <var class="Vt">u8q_t</var>,
    <var class="Vt">s16q_t</var>, <var class="Vt">u16q_t</var>,
    <var class="Vt">s32q_t</var>, <var class="Vt">u32q_t</var>,
    <var class="Vt">s64q_t</var>, and <var class="Vt">u64q_t</var>, which are
    referred to generically as <var class="Fa">QTYPE</var>. The
    <var class="Fa">ITYPE</var> refers to the <a class="Xr">stdint(7)</a>
    integer types.</p>
<p class="Pp">For more details, see <a class="Xr">qmath(3)</a>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN
  VALUES</a></h1>
<p class="Pp"><code class="Fn">Q_QADDI</code>(),
    <code class="Fn">Q_QDIVI</code>(), <code class="Fn">Q_QMULI</code>(),
    <code class="Fn">Q_QSUBI</code>(), <code class="Fn">Q_QFRACI</code>() and
    <code class="Fn">Q_QCPYVALI</code>() functions return 0 on success, or an
    errno on failure. <code class="Er">EINVAL</code> is returned for
    divide-by-zero. <code class="Er">EOVERFLOW</code> and
    <code class="Er">ERANGE</code> are returned for overflow and underflow
    respectively.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr">errno(2)</a>, <a class="Xr">qmath(3)</a>,
    <a class="Xr">stdint(7)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<p class="Pp">The <a class="Xr">qmath(3)</a> functions first appeared in
    <span class="Ux">FreeBSD 13.0</span>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">The <a class="Xr">qmath(3)</a> functions and this manual page were
    written by <span class="An">Lawrence Stewart</span>
    &lt;<a class="Mt" href="mailto:lstewart@FreeBSD.org">lstewart@FreeBSD.org</a>&gt;
    and sponsored by Netflix, Inc.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">July 8, 2018</td>
    <td class="foot-os">FreeBSD 15.0</td>
  </tr>
</table>