• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stillwater-sc / universal / 24956675961
84%
master: 84%

Build:
Build:
LAST BUILD BRANCH: fix/issue-1002-ereal-highprec-constants
DEFAULT BRANCH: master
Ran 26 Apr 2026 12:57PM UTC
Jobs 1
Files 644
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

26 Apr 2026 12:30PM UTC coverage: 84.313% (+0.01%) from 84.3%
24956675961

push

github

web-flow
feat(math): add constexpr sqrt to sw::math::constexpr_math (#772)

* feat(math): add constexpr sqrt to sw::math::constexpr_math

Adds constexpr<float|double> sqrt to the constexpr_math facility (#763
Epic, #423/PR #762 substrate). Tier-2 sub-issue: independent of all
other constexpr_math functions, used for normalization, range constants,
and complex magnitude.

Algorithm:
  Decompose x = 2^E * M with M in [1, 2). If E is odd, absorb a factor
  of 2 into M and decrement E so it becomes even. Then
    sqrt(x) = sqrt(M) * 2^(E/2)
  with 2^(E/2) constructed exactly via detail::pow2 and sqrt(M) computed
  via Newton's iteration y_{n+1} = 0.5 * (y_n + M/y_n).

  Newton has quadratic convergence: starting from y_0 = 1.5 (worst-case
  ~2 bits accurate over M in [1, 4)), each iteration roughly doubles
  the bit-precision (2 -> 4 -> 8 -> 16 -> 32 -> 64 -> 128). Six
  iterations for double, four for float -- both well past their
  significand widths.

Special-value handling per IEEE-754:
  sqrt(NaN)   -> NaN
  sqrt(x<0)   -> NaN  (including -inf)
  sqrt(+/-0)  -> +/-0  (sign preserved)
  sqrt(+inf)  -> +inf

Self-contained: only depends on detail::pow2 (already in the facility)
and std::bit_cast.

Verification:
  - 22 static_asserts: perfect squares (bit-exact via Newton convergence
    to fixed point), sqrt(2) and sqrt(3) tolerance, cross-check against
    detail::SQRT2, special values (NaN/+/-inf/+/-0), wide dynamic range
  - Runtime sweep over 23 hand-picked points + subnormal sample +
    round-trip stress (sqrt(x)^2 ~= x)
  - Float sweep over 10 points

Out-of-band accuracy stress (100K random samples in [1e-100, 1e100]):
  max relative error 2.22e-16 = 1.00 x double epsilon (1 ulp)
  -- equivalent to std::sqrt accuracy

cm_log2, cm_exp2, cm_log, cm_pow, cm_sqrt all PASS on gcc and clang.

Resolves #767
Relates to #763 (Epic)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(math): pin sqrt(-0) sign preservation explicitly (Code... (continued)

82 of 97 new or added lines in 2 files covered. (84.54%)

45439 of 53893 relevant lines covered (84.31%)

6358923.24 hits per line

Uncovered Changes

Lines Coverage ∆ File
9
76.92
internal/constexpr_math/api/sqrt.cpp
6
89.66
include/sw/math/constexpr_math/sqrt.hpp
Jobs
ID Job ID Ran Files Coverage
1 24956675961.1 26 Apr 2026 12:57PM UTC 644
84.31
GitHub Action Run
Source Files on build 24956675961
  • Tree
  • List 644
  • Changed 3
  • Source Changed 0
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #24956675961
  • cf2932c4 on github
  • Prev Build on main (#24955899585)
  • Next Build on main (#24956707653)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc