|
Boost : |
From: Matt Borland (matt_at_[hidden])
Date: 2025-01-21 19:26:51
On Tuesday, January 21st, 2025 at 2:15 PM, Peter Dimov via Boost <boost_at_[hidden]> wrote:
>
>
> > Assuming normalized numbers (which should be the case) of the same sign,
>
> > operator< is equivalent (NaN notwithstanding) to comparing the two integers
> >
> > eeeeeeee... mmmmmmmmmm...
> >
> > I'm not quite sure whether zero needs to be a special case here. There's special
> > case logic in operator< for it, but I'm not positive it's needed.
>
>
> The current operator< is this:
>
> https://godbolt.org/z/Tj7Me5aW3
>
> This is a sketch of what I was thinking about:
>
> https://godbolt.org/z/9M1cevYef
>
> I haven't run this against the test suite, so it might not be quite correct,
> but it looks correct to me. :-)
>
> It assumes that zeroes are normalized. The current implementation seems
> to not assume that; it handles 0e+7, but since the _fast types are supposed
> to be normalized, this should never happen, should it?
>
For fast types everything is normalized. Originally I was just skipping the decoding step by storing in the struct, but then after profiling adding normalization to the constructor provided significant gains. I guess I never removed all the old assumptions.
> > This makes me wonder whether { uintNN_t exp_and_mant; bool sign; }
> > wouldn't be a better representation for _fast, although that would depend on
> > how important comparisons are, performance-wise.
>
>
> Should look somewhat like this:
>
> https://godbolt.org/z/bqWKxbdjd
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk