c++ - How to get boost multiprecision number parts? -
say have number:
// bmp = boost::multiprecision bmp::cpp_dec_float n("123456789.1234567891011121314"); its backend data are:
[0] 1 unsigned int [1] 23456789 unsigned int [2] 12345678 unsigned int [3] 91011121 unsigned int [4] 31400000 unsigned int ... 0 [15] 0 unsigned int which want get; unfortunately, don't find way either both parts of number bmp::int128_t --for instance--, or underlying data of number.
that is, exists:
bmp::int128_t integerpart; bmp::int128_t floatpart; n.getparts(integerpart, floatpart); or
auto&& data = n.data(); // private when using `cpp_dec_float`. anyway, known how trying achieve?
for record, need express big decimal number c# decimal sake of interoperability.
from boost documentation end intentionally opaque may change @ time without warning. (class template cpp_dec_float fulfils of requirements backend type. members , non-member functions deliberately not documented: these considered implementation details subject change.) http://www.boost.org/doc/libs/1_55_0/libs/multiprecision/doc/html/boost_multiprecision/ref/cpp_dec_ref.html
as far can see have 2 choices here. can @ source code specific version of backend class you're using, access number using backend method, , hope backend never changes (especially consider changes broke binary format , not compilation).
alternately recommend take string representation of cpp_dec_float , split 2 parts yourself, using string or char* constructors underlying integral types you're interested in.
Comments
Post a Comment