You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IEEE 754 specifies two different encodings for decimal floating point types: Binary Integer Significand Field (BID), and Densely Packed Decimal Significand Field (DPD).
12
+
The former is designed for software implementations and the latter for hardware implementations.
12
13
Internally this library is implemented in the BID format for the IEEE-754 compliant types.
13
14
Should the user want to capture the bit format in BID or convert to DPD we offer a family of conversion functions: `to_bid`, `from_bid`, `to_dpd`, and `from_dpd` that allow conversion to or from the bit strings regardless of encoding.
14
15
@@ -114,3 +115,54 @@ constexpr T from_dpd(unsigned __int128 bits) noexcept;
114
115
} // namespace decimal
115
116
} // namespace boost
116
117
----
118
+
119
+
== Bit Conversions Example
120
+
121
+
The following example is copied and pasted from the examples/ folder of the library and is called https://github.com/cppalliance/decimal/blob/develop/examples/bit_conversions.cpp[bit_conversions.cpp].
122
+
123
+
[source, c++]
124
+
----
125
+
#include <boost/decimal/decimal32_t.hpp>
126
+
#include <boost/decimal/dpd_conversion.hpp>
127
+
#include <boost/decimal/bid_conversion.hpp>
128
+
#include <iostream>
129
+
130
+
int main()
131
+
{
132
+
using boost::decimal::decimal32_t;
133
+
using boost::decimal::from_bid;
134
+
using boost::decimal::from_dpd;
135
+
using boost::decimal::to_bid;
136
+
using boost::decimal::to_dpd;
137
+
138
+
// First we construct a decimal value and then convert it into both BID and DPD encoded bits
0 commit comments