GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Q_QADDQ(3) FreeBSD Library Functions Manual Q_QADDQ(3)

Q_QADDQ, Q_QDIVQ, Q_QMULQ, Q_QSUBQ, Q_NORMPREC, Q_QMAXQ, Q_QMINQ, Q_QCLONEQ, Q_CPYVALQ
fixed-point math functions which operate on two Q numbers

#include <sys/qmath.h>

int
Q_QADDQ(QTYPE *a, QTYPE b);

int
Q_QDIVQ(QTYPE *a, QTYPE b);

int
Q_QMULQ(QTYPE *a, QTYPE b);

int
Q_QSUBQ(QTYPE *a, QTYPE b);

int
Q_NORMPREC(QTYPE *a, QTYPE *b);

QTYPE
Q_QMAXQ(QTYPE a, QTYPE b);

QTYPE
Q_QMINQ(QTYPE a, QTYPE b);

int
Q_QCLONEQ(QTYPE *l, QTYPE r);

int
Q_QCPYVALQ(QTYPE *l, QTYPE r);

The Q_QADDQ(), Q_QDIVQ(), Q_QMULQ(), and Q_QSUBQ() functions add, divide, multiply or subtract b to/by/from a respectively, storing the result in a. Both arguments must be initialized with the same fractional radix point.

The Q_NORMPREC() function attempts to normalise the precision of a and b if they differ. The greater of the two precisions is preferred if possible, unless that would truncate integer component data for the other operand, in which case the highest precision that preserves the integer component of both a and b is selected.

The Q_QMAXQ() and Q_QMINQ() functions return the larger or smaller of a and b respectively.

The Q_QCLONEQ() and Q_QCPYVALQ() functions attempt to store identical or representational copies of r, in l respectively. An identical Q number produced by cloning copies the control bits as well as the verbatim integer/fractional bits. A representational copy only copies the values of r's integer and fractional bits, representing them in the bits available per l's Q format.

All of those functions operate on the following data types: s8q_t, u8q_t, s16q_t, u16q_t, s32q_t, u32q_t, s64q_t, and u64q_t, which are referred to generically as QTYPE.

For more details, see qmath(3).

The Q_QADDQ(), Q_QDIVQ(), Q_QMULQ(), Q_QSUBQ() Q_NORMPREC(), Q_QCLONEQ() and Q_QCPYVALQ() functions return 0 on success, or an errno on failure. EINVAL is returned for divide-by-zero. EOVERFLOW and ERANGE are returned for overflow and underflow respectively. ERANGE is also returned when the precision of arguments does not match.

The Q_QMAXQ() and Q_QMINQ() functions return the numerically larger or smaller of their two inputs respectively.

errno(2), qmath(3), stdint(7)

The qmath(3) functions first appeared in FreeBSD 13.0.

The qmath(3) functions and this manual page were written by Lawrence Stewart <lstewart@FreeBSD.org> and sponsored by Netflix, Inc.
July 8, 2018 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.