xersi xersi - 1 year ago 76
C++ Question

Assign a BigInteger to a normal integer

For example, I can do this :

uint64_t a = 100;
BigInteger b = a;

But I can't do this :

BigInteger a = 100;
uint64_t b = a;

Is there any way? Thanks.

Answer Source

The simplest solution is to make BigInteger implicitly convertible to uint64_t. This can be achieved with a conversion operator:

BigInteger::operator uint64_t();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download