![]() |
Boost : |
From: Matt Borland (matt_at_[hidden])
Date: 2025-02-01 19:41:36
>
>
> John Maddock wrote:
>
> > In late breaking news, I also hear from Matt that GCC and IBM both "cheat" by using (mutually incompatible) non-IEEE binary encodings.
>
>
> Are these documented anywhere? It would be interesting to look at them for inspiration.
>
I wish. They docs just say BID format. Here is what IEEE 754 specifies:
https://github.com/cppalliance/decimal/blob/develop/include/boost/decimal/decimal32.hpp#L72-L102
Here is what I gathered from trying to wrap the builtin libstdc++ (IBM) types:
I kept dumping the bits of powers of two etc to figure it out:
Basically, it's laid out like a binary float most of the time. In Intel's case for implementation of mathematical functions they convert the Decimal32 to a float, perform an operation, and then convert back. Makes things pretty quick when your conversion operation is NOP, and then you can offload computations to presumably the MKL.
Matt
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk