Q function
pyfxp.Q
Create a fixed-point format specification using ARM-style Q-format notation.
The Q function defines a fixed-point representation by specifying
the number of integer and fractional bits, whether the format is signed,
and how rounding and overflow are handled. It returns an FxpSpec object
that can be passed to other functions (e.g., fxp) for actual numeric conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qi
|
int
|
Number of integer bits. |
required |
qf
|
int
|
Number of fractional bits. |
required |
signed
|
bool
|
Whether the fixed-point format is signed (default is True). |
True
|
rnd
|
int
|
Rounding method to apply (default is TRUNC (0)). Supported methods:
|
TRUNC
|
ovf
|
int
|
Overflow handling method (default is WRAP (0)). Supported methods:
|
WRAP
|
Returns:
| Type | Description |
|---|---|
FxpSpec
|
A specification object describing the fixed-point format. |
Notes
This function uses ARM-style Q-format notation:
Qm.nindicatesminteger bits andnfractional bits (ARM style).- The returned
FxpSpeccan be reused for consistent conversions across multiple values.
Examples: