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

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

Build:
Build:
LAST BUILD BRANCH: fix/issue-ci-ereal-regression-runtime
DEFAULT BRANCH: master
Ran 16 May 2026 06:10PM UTC
Jobs 1
Files 649
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

16 May 2026 05:42PM UTC coverage: 83.966% (-0.02%) from 83.984%
25968650216

push

github

web-flow
feat(utility): high-precision decimal-to-binary converter (Phase B2a of #835) (#841)

* feat(utility): high-precision decimal-to-binary converter (Phase B2a of #835)

Adds include/sw/universal/utility/decimal_to_binary.hpp -- a multi-limb
bignum-based converter that turns a string_parse::scan_decimal_float
result into a normalized binary representation (sign, mantissa as wide
integer, binary scale, guard bit, sticky bit) with enough precision for
any Universal number system to encode with correct round-to-nearest-even
rounding.

This is the shared foundation that Phase B2b (posit) and B2c (cfloat)
will consume. Wiring those types is intentionally out of scope here;
this PR is utility + validation only.

Algorithm
---------
Given input "[+-]?int.frac[eE][+-]?exp" parsed into (M, E):

  E >= 0:  mantissa = M * 5^E,  binary scale of LSB = E
  E <  0:  let neg_E = |E|, K = headroom + 4*neg_E.
           mantissa = floor((M << (K - neg_E)) / 5^neg_E)
           binary scale of LSB = -K
           The K = headroom + 4*neg_E overshoots log2(5) ~= 2.32 with
           generous margin so the post-divide quotient retains
           target_mantissa_bits + 2 useful bits regardless of |E|.

Then normalize the mantissa so its MSB sits at target_mantissa_bits - 1.
Bits dropped during the right-shift feed `guard_bit` and `sticky_bit`;
the divide remainder also OR's into `sticky_bit`.

Implementation notes
--------------------
- Uses `sw::universal::integer<2048, std::uint32_t, IntegerNumber>` as the
  internal bignum (template-overridable via the `BigBits` parameter for
  callers that need wider). 2048 bits comfortably covers IEEE-double
  exponent range (E up to ~600) and standard posit/cfloat targets.
- Does NOT use `einteger<>` (the elastic integer): it currently produces
  bit-exact wrong results for certain large-operand division patterns
  this code path exercises (e.g., M=3141592653589793, shift=100, divide
  by 5^15 -- einteger gives a quotient 2^64 too high;... (continued)

46093 of 54895 relevant lines covered (83.97%)

6456216.63 hits per line

Coverage Regressions

Lines Coverage ∆ File
10
31.43
-3.57% include/sw/universal/verification/test_suite_randoms.hpp
5
50.45
-4.5% include/sw/universal/verification/posit_test_suite_randoms.hpp
1
80.58
-0.22% include/sw/universal/number/posit1/specialized/posit_16_1.hpp
Jobs
ID Job ID Ran Files Coverage
1 25968650216.1 16 May 2026 06:10PM UTC 649
83.97
GitHub Action Run
Source Files on build 25968650216
  • Tree
  • List 649
  • Changed 4
  • Source Changed 0
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #25968650216
  • f75e7cda on github
  • Prev Build on main (#25962944285)
  • Next Build on main (#25970302245)
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