2 .\" Copyright (c) 2018 Netflix, Inc.
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions, and the following disclaimer,
10 .\" without modification, immediately at the beginning of the file.
11 .\" 2. The name of the author may not be used to endorse or promote products
12 .\" derived from this software without specific prior written permission.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 .\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 .Nd fixed-point math functions which operate on two Q numbers
45 .Fn Q_QADDQ "QTYPE *a" "QTYPE b"
47 .Fn Q_QDIVQ "QTYPE *a" "QTYPE b"
49 .Fn Q_QMULQ "QTYPE *a" "QTYPE b"
51 .Fn Q_QSUBQ "QTYPE *a" "QTYPE b"
53 .Fn Q_NORMPREC "QTYPE *a" "QTYPE *b"
55 .Fn Q_QMAXQ "QTYPE a" "QTYPE b"
57 .Fn Q_QMINQ "QTYPE a" "QTYPE b"
59 .Fn Q_QCLONEQ "QTYPE *l" "QTYPE r"
61 .Fn Q_QCPYVALQ "QTYPE *l" "QTYPE r"
69 functions add, divide, multiply or subtract
73 respectively, storing the result in
75 Both arguments must be initialized with the same fractional radix point.
79 function attempts to normalise the precision of
84 The greater of the two precisions is preferred if possible, unless that would
85 truncate integer component data for the other operand, in which case the highest
86 precision that preserves the integer component of both
96 functions return the larger or smaller of
106 functions attempt to store identical or representational copies of
111 An identical Q number produced by cloning copies the control bits as well as the
112 verbatim integer/fractional bits.
113 A representational copy only copies the values of
115 integer and fractional bits, representing them in the bits available per
119 All of those functions operate on the following data types:
129 which are referred to generically as
132 For more details, see
144 functions return 0 on success, or an errno on failure.
146 is returned for divide-by-zero.
150 are returned for overflow and underflow respectively.
151 .Er ERANGE is also returned when the precision of arguments
158 functions return the numerically larger or smaller of their two inputs
167 functions first appeared in
173 functions and this manual page were written by
174 .An Lawrence Stewart Aq Mt lstewart@FreeBSD.org
175 and sponsored by Netflix, Inc.