Skip to content

Constants

pyfxp.constants

Fixed-point arithmetic constants.

Attributes:

Name Type Description
TRUNC

Bit truncation. Rounds toward negative infinity.

CEIL

Round toward positive infinity.

TO_ZERO

Round toward zero.

AWAY

Round away from zero.

HALF_UP

Round to nearest; ties round toward positive infinity.

HALF_DOWN

Round to nearest; ties round toward negative infinity.

HALF_EVEN

Round to nearest; ties to even.

HALF_ZERO

Round to nearest; ties toward zero.

HALF_AWAY

Round to nearest; ties away from zero.

WRAP

Overflow wraps around.

SAT

Overflow saturates to max/min representable value.

ERROR

Overflow raises an error.

rounding_modes

Dictionary mapping rounding mode names to their numeric codes.

overflow_modes

Dictionary mapping overflow mode names to their numeric codes.

rounding_modes_inv

Inverse mapping of rounding mode codes to names.

overflow_modes_inv

Inverse mapping of overflow mode codes to names.

TRUNC module-attribute

TRUNC = 0

Bit truncation. Rounds toward negative infinity.

CEIL module-attribute

CEIL = 1

Round toward positive infinity.

TO_ZERO module-attribute

TO_ZERO = 2

Round toward zero.

AWAY module-attribute

AWAY = 3

Round away from zero.

HALF_UP module-attribute

HALF_UP = 4

Round to nearest; ties round toward positive infinity.

HALF_DOWN module-attribute

HALF_DOWN = 5

Round to nearest; ties round toward negative infinity.

HALF_EVEN module-attribute

HALF_EVEN = 6

Round to nearest; ties to even.

HALF_ZERO module-attribute

HALF_ZERO = 7

Round to nearest; ties toward zero.

HALF_AWAY module-attribute

HALF_AWAY = 8

Round to nearest; ties away from zero.

WRAP module-attribute

WRAP = 0

Overflow wraps around.

SAT module-attribute

SAT = 1

Overflow saturates to max/min representable value.

ERROR module-attribute

ERROR = 2

Overflow raises an error.

rounding_modes module-attribute

rounding_modes = {
    "TRUNC": TRUNC,
    "CEIL": CEIL,
    "TO_ZERO": TO_ZERO,
    "AWAY": AWAY,
    "HALF_UP": HALF_UP,
    "HALF_DOWN": HALF_DOWN,
    "HALF_EVEN": HALF_EVEN,
    "HALF_ZERO": HALF_ZERO,
    "HALF_AWAY": HALF_AWAY,
}

Dictionary mapping rounding mode names to their numeric codes.

overflow_modes module-attribute

overflow_modes = {'WRAP': WRAP, 'SAT': SAT, 'ERROR': ERROR}

Dictionary mapping overflow mode names to their numeric codes.

rounding_modes_inv module-attribute

rounding_modes_inv = {v: _afor (k, v) in (items())}

Inverse mapping of rounding mode codes to names.

overflow_modes_inv module-attribute

overflow_modes_inv = {v: _Ifor (k, v) in (items())}

Inverse mapping of overflow mode codes to names.