Boost logo

Boost Users :

From: John Maddock (jz.maddock_at_[hidden])
Date: 2023-05-27 19:08:25


On 27/05/2023 19:15, Matthew Mawson via Boost-users wrote:
> I want to assign a large number to a cpp_int variable like this:
>
> cpp_int large = 30414093201713378043612608166064768844377641568960512000000000000;
>
> and I get this: error: integer literal is too large to be represented in any integer type.

You're compiler is correct, there are two ways around this, the first is
assignment from a string, which must be an explicit cast or construction:

cpp_int
large{"30414093201713378043612608166064768844377641568960512000000000000"};

Or you can create extended precision literals, but these must be in hex
format, see
https://www.boost.org/doc/libs/1_82_0/libs/multiprecision/doc/html/boost_multiprecision/tut/lits.html

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