Boost logo

Boost :

From: Matt Borland (matt_at_[hidden])
Date: 2025-01-21 16:45:04


> Assuming normalized numbers (which should be the case)...

This is not the case for the decimalXX types. IEEE 754 requires proper handling of cohorts (e.g. 1e-1 has a different bit pattern than 10e-2) so we have to normalize them before we can compare. The fast types normalize in the constructor to get rid of this effect.

>...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.
>

> 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.
>

> We can actually apply a similar trick to BID encoding, by first checking whether the exponents start with something other than 11.
> In that case, we can use a single compare without having to unpack.
>

> (And if not, do something else clever :-) )
>

>

>

> _______________________________________________
> 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