Skip to content

t27b: std.math.pow(f32, ..) from libm.t27 (Zig's std/math/pow.zig); gf16.t27 passes #7823

Closed

Description

@gHashTag

Part of #7746 (t27b passes specs/numeric/gf16.t27), which is part of #6063 (t27b coverage), item C10 of #6488. This is the last PR of #7746's split, after #7791, #7819 and #7822. It makes gf16.t27 pass and closes #7746.

What gf16.t27 needs

gf16_pow calls std.math.pow(f32, base_val, exp_val), and gf16_pow_two_cubed and others reach it. After #7822 it is gf16.t27's last blocker (ExprCall(std.*), call to std.math.pow).

What the reference does

std.math.pow(f32, x, y) is not compiler_rt. It is Zig 0.16's std/math/pow.zig, a port of Go's math.Pow:

  • The special cases come first: y = +-0, x = 1, a NaN, y = 1, x = +-0, y = +-inf and x = +-inf.
  • y == 0.5 is @sqrt(x).
  • Otherwise y is split by math.modf (an f32 @trunc). The fractional part gives @exp(yf * @log(x)), the f32 expf and logf. The integer part is a square-and-multiply on math.frexp(x), and the result is math.scalbn(a1, ae), which is math.ldexp, with its own rounding of a subnormal result.
  • isOddInteger takes an f64 and calls the f64 math.modf.
  • A NaN result of the special cases is math.nan(f32), 0x7FC00000.
  • Measured on the t27c lab: a comptime-folded std.math.pow(f32, ..) equals the run-time call on a 49-point grid.

Plan

Acceptance criteria

  • t27b test --blockers specs/numeric/gf16.t27 reports nothing.
  • t27b test specs/numeric/gf16.t27 passes every test that t27c test-report passes, with the same verdicts.
  • The lab corpus receipt compare gives IMPROVED_ONLY, EQUIVALENT or NEUTRAL.

User Scenarios

  • Given the specs/numeric/gf16.t27 spec calls std.math.pow(f32, ...) via gf16_pow, When t27b test --blockers specs/numeric/gf16.t27 is run, Then it reports no blockers for std.math.pow.
  • Given the specs/tri/t27b/libm.t27 file implements powf for f32 with frexp, ldexp, isOddInteger, and trunc from compiler_rt, When t27b test specs/numeric/gf16.t27 runs, Then every test passes with the same verdicts as t27c test-report.

Requirements

  • FR-001: specs/tri/t27b/libm.t27 MUST implement powf for f32 matching Zig 0.16's std/math/pow.zig special cases and algorithm.
  • FR-002: specs/tri/t27b/libm.t27 MUST provide frexp and ldexp for f32, isOddInteger using f64 modf, and use compiler_rt's f64 trunc.
  • FR-003: specs/tri/t27b/libm_plan.t27 MUST declare std.math.pow as taking three operands (type, base, exponent), route f32 to powf, and refuse f64.
  • FR-004: The implementation MUST produce bit-for-bit identical results to the reference over grids of x and y values.

Boundary

  • specs/numeric/gf16.t27
  • specs/tri/t27b/libm.t27
  • specs/tri/t27b/libm_plan.t27

Activity

  1. added 2 commits that reference this issue on Oct 9, 2026
    d53834b
    4c62c73
  2. added a commit that references this issue on Oct 9, 2026
    9abff10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions