Skip to content

Preserve representable subnormal results for negative integer powers #557

Closed

Description

@LunaStev

pow_f32_i32 and pow_f64_i32 first compute the positive power, then take its reciprocal for negative exponents. If the positive power overflows, the reciprocal becomes zero even when the actual negative power is representable as a subnormal. Examples are pow_f32_i32(2.0, -128) and pow_f64_i32(2.0, -1024). This is premature intermediate overflow, not unavoidable underflow of the requested result.

Code evidence:

Acceptance:

  • Handle negative exponents without requiring an overflowing positive-power intermediate.
  • Add exact power-of-two subnormal cases, including the smallest representable power where supported.
  • Retain behavior for exponent zero, minimum i32 exponent, negative bases with odd/even exponents, signed zero and non-finite inputs.
  • Verify normal-range powers as well as underflow/overflow boundaries without adding a math-library dependency.

Audit status: static source inspection against canonical master ea74c2dafc31da876e5561f2d176ba719f5a0458 on 2026-09-10. No compiler build, test execution, implementation change or local reproduction was performed for this report. The examples describe the source-derived behavior to verify when implementing the fix.

Activity

  1. added
    bug
    help wanted
    on Sep 10, 2026
  2. added a commit that references this issue on Sep 16, 2026
    451cc7a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions