Q_SIGNED(3)
okay bestie, welcome to Q_SIGNED(3) from the Library Functions Manual π this is the group chat for the fixed-point math comparison and logic functions, and honestly? they ate. no cap.
β¨ NAME β¨
the squad is Q_SIGNED, Q_LTZ, Q_PRECEQ, Q_QLTQ, Q_QLEQ, Q_QGTQ, Q_QGEQ, Q_QEQ, Q_QNEQ, Q_OFLOW, and Q_RELPREC β all here for fixed-point math comparison and logic functions π₯
π§ SYNOPSIS π§
include this header first, bestie:
#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);
π DESCRIPTION π
okay so, function-by-function, no skipping:
Q_SIGNED(NTYPE n)β returnstrueif the numeric data type passed in asnis signed, andfalseotherwise. πQ_LTZ(NTYPE n)β returnstrueif the numeric value passed in asnis negative (this one requires types which use the MSB as the sign bit), andfalseotherwise. πQ_PRECEQ(QTYPE a, QTYPE b)β returnstrueif the number ofaandbfractional bits is the same, andfalseotherwise. β¨Q_QLTQ(QTYPE a, QTYPE b)β compares two Q numbers; returnstrueifais less thanb, andfalseotherwise. π¦Q_QLEQ(QTYPE a, QTYPE b)β compares two Q numbers; returnstrueifais less than or equal tob, andfalseotherwise. πΈQ_QGTQ(QTYPE a, QTYPE b)β compares two Q numbers; returnstrueifais greater thanb, andfalseotherwise. π₯Q_QGEQ(QTYPE a, QTYPE b)β compares two Q numbers; returnstrueifais greater than or equal tob, andfalseotherwise. πQ_QEQ(QTYPE a, QTYPE b)β compares two Q numbers; returnstrueifais equal tob, andfalseotherwise. βQ_QNEQ(QTYPE a, QTYPE b)β compares two Q numbers; returnstrueifais not equal tob, andfalseotherwise. πQ_OFLOW(QTYPE q, ITYPE iv)β returnstrueif integer valueivcannot be stored inqwithout truncation, andfalseotherwise. π«ΆQ_RELPREC(QTYPE a, QTYPE b)β returns the relative precision ofaversusb. in terms ofQm.nnotation, this function returns the difference between thenvalues ofaandb. for example, a return value of+4means thatahas an additional 4 bits of fractional precision compared tob. πΊ
for the comparison crew (Q_QLTQ(), Q_QLEQ(), Q_QGTQ(), Q_QGEQ(), Q_QEQ() and Q_QNEQ()), the integral and fractional values are used to perform the comparison, without explicit concern for the underlying number of integer versus fractional bits. π€
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).
π RETURN VALUES π
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. π’
π SEE ALSO π
β HISTORY β
The qmath(3) functions first appeared in FreeBSD 13.0. π
π«Ά AUTHORS π«Ά
The qmath(3) functions and this manual page were written by Lawrence Stewart <lstewart@FreeBSD.org> and sponsored by Netflix, Inc. π
mwah π this page came from Debian, dated July 8, 2018, and it's the Q_SIGNED(3) manual page. periodt. π
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2018 Netflix, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms