|
Boost : |
From: Matt Borland (matt_at_[hidden])
Date: 2025-01-21 20:06:21
On Tuesday, January 21st, 2025 at 2:51 PM, Peter Dimov via Boost <boost_at_[hidden]> wrote:
>
>
> > > 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
>
>
> Here's the current operator==:
>
> https://godbolt.org/z/qc54e3hxT
>
> It's not that bad but (1) it's wrong because it says -0 != +0 and (2)
> is_zero doesn't optimize well.
>
> Here's operator== when using packed exponent+mantissa:
>
> https://godbolt.org/z/sE7f3fWf5
>
> The number of instructions in op== doesn't decrease much,
> but in practice it should be much faster because of the early
> reject that will be taken most of the time.
>
> Also, see how much better is_zero becomes.
>
This design could be worth investigation. We looked at bitfields originally, but since they require C++20 for constexpr support it wasn't worth pursuing.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk