Commit e9d2558
committed
fix(efloat): resolve CodeRabbit functional correctness comments
1. Fix division rounding sign tracking: pass result_sign (computed as (_sign != rhs._sign))
to round_limbs in operator/= rather than the pre-operation dividend's _sign, which
resolves directional division rounding sign mismatches.
2. Protect normalize() from erasing NaN/Inf: add a guard to normalize() to early-return
if _state is not FloatingPointState::Normal, preserving exceptional states.
3. Fix inexact division bit-loss: in divide_limbs, accumulate remainder_non_zero inside the
shift loop, capturing any bits that overflow and shift out of dvd, making inexact
divisions 100% mathematically correct and robust.
4. Add division rounding regression tests: add tests for efloat<1>(1.0) / efloat<1>(3.0)
under different rounding modes inside rounding.cpp to throroughly cover the division
sticky-remainder and sign-tracking flows.
Resolves #1091, PR #11041 parent 2a95809 commit e9d2558
2 files changed
Lines changed: 45 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
147 | 177 | | |
148 | 178 | | |
149 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
362 | 363 | | |
363 | 364 | | |
364 | | - | |
| 365 | + | |
365 | 366 | | |
366 | 367 | | |
367 | 368 | | |
368 | 369 | | |
369 | 370 | | |
370 | 371 | | |
371 | | - | |
| 372 | + | |
372 | 373 | | |
373 | 374 | | |
374 | 375 | | |
| |||
465 | 466 | | |
466 | 467 | | |
467 | 468 | | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
468 | 473 | | |
469 | 474 | | |
470 | 475 | | |
| |||
663 | 668 | | |
664 | 669 | | |
665 | 670 | | |
| 671 | + | |
666 | 672 | | |
667 | 673 | | |
668 | 674 | | |
| |||
679 | 685 | | |
680 | 686 | | |
681 | 687 | | |
| 688 | + | |
682 | 689 | | |
683 | 690 | | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
689 | 697 | | |
690 | 698 | | |
691 | 699 | | |
| |||
0 commit comments