|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2025-01-21 19:15:39
> 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?
> 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