 
| Main index | Section 3 | Options | 
#include <sys/qmath.h>
The Q_NCBITS defined constant specifies the number of reserved control bits, currently 3.
Q_NTBITS(), Q_NFCBITS(), Q_MAXNFBITS(), Q_NFBITS() and Q_NIBITS() return the q, Ns, -specific count of total, control-encoded fractional, maximum fractional, effective fractional, and integer bits applicable to q respectively.
Q_BT() returns the C data type of q, while Q_TC() returns v type casted to the C data type of q.
Q_RPSHFT() returns the bit position of q, Ap, s binary radix point relative to bit zero.
Q_ABS() returns the absolute value of any standard numeric type (that uses the MSB as a sign bit, but not Q numbers) passed in as n. The function is signed/unsigned type safe.
Q_SHL() and Q_SHR() return the integral value v left or right shifted by the appropriate amount for q.
Q_MAXSTRLEN() calculates the maximum number of characters that may be required to render the C-string representation of q with numeric base base.
Q_TOSTR() renders the C-string representation of q with numeric base base and fractional precision prec into s which has an available capacity of slen characters. base must be in range [2,16]. Specifying prec as -1 renders the number's fractional component with maximum precision. If slen is greater than zero but insufficient to hold the complete C-string, the '\0' C-string terminator will be written to *s, thereby returning a zero length C-string.
Q_DEBUG() returns a format string and associated data suitable for printf-like rendering of debugging information pertaining to q. If either prefmt and/or postfmt are specified, they are prepended and appended to the resulting format string respectively. The incfmt boolean specifies whether to include (true) or exclude (false) the raw format string itself in the debugging output.
Q_DFV2BFV() converts decimal fractional value dfv to its binary-encoded representation with nfbits of binary precision. dfv must be passed as a preprocessor literal to preserve leading zeroes. The returned value can be used to set a Q number's fractional bits, for example using Q_SFVAL().
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).
Q_TOSTR() returns a pointer to the '\0' C-string terminator appended to s after the rendered numeric data, or NULL on buffer overflow.
Q_DFV2BFV() returns the binary-encoded representation of decimal fractional value dfv with nfbits of binary precision.
| Q_INI (3) | July 8, 2018 | 
 
| Main index | Section 3 | Options | 
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
| “ | One of the advantages of using UNIX to teach an operating systems course is the sources and documentation will easily fit into a student's briefcase. | ” | 
| — John Lions | ||