|
Boost Users : |
Subject: Re: [Boost-users] Cpp_int and cpp_dec_float conversion
From: John Maddock (john_at_[hidden])
Date: 2013-04-24 06:32:43
>There is an explicit conversion from cpp_int to cpp_dec_float, but no
>conversion in the opposite direction (in general it's unsafe).
Forgot to say: if you really must convert from cpp_dec_lfoat to cpp_int you
could do:
cpp_int i(my_big_float.str(0, std::ios_base::fixed));
Just make sure the float really is an integer first (use
ceil/floor/trunc/round if necessary) otherwise the conversion will fail.
HTH, John.
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