irx.analysis.float_literals

irx.analysis.float_literals

Source: packages/irx/src/irx/analysis/float_literals.py

title: Single-rounding conversion of exact values to supported binary formats.
summary: >-
  Resolve decimal and integer literals with exact integer arithmetic before
  constructing a host float. No intermediate binary64 rounding, ambient Decimal
  precision, or LLVM behavior determines the selected target value.

Functions

rounded_float(value: int | float | Decimal, target: astx.DataType) -> float

title: Round once to the target binary format, nearest with ties to even.
summary: >-
  Include subnormals, signed zero, and overflow to infinity. Callers decide
  whether a nonfinite result is legal. Existing floating NaN/infinity are
  preserved; finite decimals are never converted through binary64 first.
parameters:
  value:
    type: int | float | Decimal
  target:
    type: astx.DataType
returns:
  type: float
raises:
  TypeError: If the target is not a supported floating format.
  ValueError: If a Decimal payload is nonfinite.
Back to top