Q_SIGNED(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

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) β€” returns true if the numeric data type passed in as n is signed, and false otherwise. πŸ’–
  • Q_LTZ(NTYPE n) β€” returns true if the numeric value passed in as n is negative (this one requires types which use the MSB as the sign bit), and false otherwise. 😭
  • Q_PRECEQ(QTYPE a, QTYPE b) β€” returns true if the number of a and b fractional bits is the same, and false otherwise. ✨
  • Q_QLTQ(QTYPE a, QTYPE b) β€” compares two Q numbers; returns true if a is less than b, and false otherwise. πŸ¦‹
  • Q_QLEQ(QTYPE a, QTYPE b) β€” compares two Q numbers; returns true if a is less than or equal to b, and false otherwise. 🌸
  • Q_QGTQ(QTYPE a, QTYPE b) β€” compares two Q numbers; returns true if a is greater than b, and false otherwise. πŸ”₯
  • Q_QGEQ(QTYPE a, QTYPE b) β€” compares two Q numbers; returns true if a is greater than or equal to b, and false otherwise. πŸ‘‘
  • Q_QEQ(QTYPE a, QTYPE b) β€” compares two Q numbers; returns true if a is equal to b, and false otherwise. βœ…
  • Q_QNEQ(QTYPE a, QTYPE b) β€” compares two Q numbers; returns true if a is not equal to b, and false otherwise. πŸ™ˆ
  • Q_OFLOW(QTYPE q, ITYPE iv) β€” returns true if integer value iv cannot be stored in q without truncation, and false otherwise. 🫢
  • Q_RELPREC(QTYPE a, QTYPE b) β€” returns the relative precision of a versus b. in terms of Qm.n notation, this function returns the difference between the n 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. 🌺

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