|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2025-01-21 19:32:20
> 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?
And here's another option, using bitfields:
https://godbolt.org/z/Y7asaMczz
GCC seems to like this better because it's able to figure out that
the exponent and the significand are adjacent in memory, so the
shift+or can be optimized out.
>
> > 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
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk