Boost logo

Boost Users :

Subject: Re: [Boost-users] multiprecision int - convert to floating type
From: John Maddock (john_at_[hidden])
Date: 2013-07-25 05:27:17


> Any suggestion how to convert a mp int (e.g., int128_t) to a float type
> (e.g.,
> double)?

The C++03 way is:

   cpp_int i = 1;
   i <<= 128;
   double d = i.convert_to<double>();

In C++11 you can just use a static_cast (explicit convertion operator).

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