man.bsd.lv manual page server

Manual Page Search Parameters

Q_SIGNED(3) Library Functions Manual Q_SIGNED(3)

Q_SIGNED, Q_LTZ, Q_PRECEQ, Q_QLTQ, Q_QLEQ, Q_QGTQ, Q_QGEQ, Q_QEQ, Q_QNEQ, Q_OFLOW, Q_RELPRECfixed-point math comparison and logic functions

#include <sys/qmath.h>

bool
Q_SIGNED(NTYPE n);

bool
Q_LTZ(NTYPE n);

bool
Q_PRECEQ(QTYPE a, QTYPE b);

bool
Q_QLTQ(QTYPE a, QTYPE b);

bool
Q_QLEQ(QTYPE a, QTYPE b);

bool
Q_QGTQ(QTYPE a, QTYPE b);

bool
Q_QGEQ(QTYPE a, QTYPE b);

bool
Q_QEQ(QTYPE a, QTYPE b);

bool
Q_QNEQ(QTYPE a, QTYPE b);

bool
Q_OFLOW(QTYPE q, ITYPE iv);

int
Q_RELPREC(QTYPE a, QTYPE b);

() returns true if the numeric data type passed in as n is signed, or false otherwise.

() returns true if the numeric value passed in as n is negative (requires types which use the MSB as the sign bit), or false otherwise.

() returns true if the number of a and b fractional bits is the same, false otherwise.

The (), (), (), (), () and () functions compare two Q numbers, returning true if a is less than, less than or equal to, greater than, greater than or equal to, equal to, or not equal to b respectively, or false otherwise. The integral and fractional values are used to perform the comparison, without explicit concern for the underlying number of integer versus fractional bits.

() returns true if integer value iv cannot be stored in q without truncation, or false otherwise.

() returns the relative precision of a versus b. In terms of notation, this function returns the difference between the values of a and b. For example, a return value of +4 means that a has an additional 4 bits of fractional precision compared to b.

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. The ITYPE refers to the stdint(7) integer types. NTYPE is used to refer to any numeric type and is therefore a superset of QTYPE and ITYPE.

For more details, see qmath(3).

The Q_SIGNED(), Q_LTZ(), Q_PRECEQ(), Q_QLTQ(), Q_QLEQ(), Q_QGTQ(), Q_QGEQ(), Q_QEQ(), Q_QNEQ() and Q_OFLOW() functions return expressions that evaluate to boolean true or false.

Q_RELPREC() returns the relative precision difference as a signed integer.

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.0