Boost Users :
Subject: [Boost-users] [boost.multiprecision] export_bits throws on a negative cpp_int number
From: Tassilo Glander (tgl_at_[hidden])
Date: 2016-04-28 03:05:34
When calling export_bits on a negative boost::multiprecision number based on cpp_int, an exception is thrown from the internal method msb ("testing individual bits in negative values is not supported").
boost::multiprecision::checked_int128_t i (-1); // use negative number
std::vector<unsigned char> v;
export_bits(i, std::back_inserter(v), 8); // throws
How can I extract the content of a boost::multiprecision number? Boost documentation says, export_bits is designed to be used for data exchange, so in my understanding it would be a major flaw, if it cannot export supported values.
I learnt that a workaround might be to directly access the backend's limbs, but this way I am accessing internals that may change.
I also asked this on http://stackoverflow.com/questions/36890928/boostmultiprecisionexport-bits-throws-on-a-negative-cpp-int-number, but this list is probably the better place.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net