---
name: "Q_QGTQ"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/Q_LTZ"
---

# Q\_QGTQ(3)

fixed-point math comparison and logic functions

Part of [Q\_LTZ(3)](/Q_LTZ/3.md).

## NAME

**Q\_SIGNED**, **Q\_LTZ**, **Q\_PRECEQ**, **Q\_QLTQ**, **Q\_QLEQ**, **Q\_QGTQ**, **Q\_QGEQ**, **Q\_QEQ**, **Q\_QNEQ**, **Q\_OFLOW**, **Q\_RELPREC** – fixed-point math comparison and logic functions

## SYNOPSIS

**#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

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

**Q\_LTZ**() 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.

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

The **Q\_QLTQ**(), **Q\_QLEQ**(), **Q\_QGTQ**(), **Q\_QGEQ**(), **Q\_QEQ**() and **Q\_QNEQ**() 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.

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

**Q\_RELPREC**() 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*.

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)](/stdint/7.md) 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)](/qmath/3.md).

## 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

[errno(2)](/errno/2.md), [qmath(3)](/qmath/3.md), [stdint(7)](/stdint/7.md)

## HISTORY

The [qmath(3)](/qmath/3.md) functions first appeared in FreeBSD 13.0.

## AUTHORS

The [qmath(3)](/qmath/3.md) functions and this manual page were written by Lawrence Stewart ⟨*lstewart@FreeBSD.org*⟩ and sponsored by Netflix, Inc.
