Dave
Dave

Reputation: 474

Convert String to BigInteger in C++

I'm using the BigInteger library. However when converting from string to BigInteger I summon the error "no matching function for call BigInteger(string&)".

How should one convert from between the two without invoking an error?

Here is a snippit of my code:

      #include "BigIntegerLibrary.hh"

      str1=randomStrGen(1);
      str2=randomStrGen(1);

      BigInteger s1 = new BigInteger(str1);
      BigInteger s2 = new BigInteger(str2);

BigInteger Library downloaded from https://mattmccutchen.net/bigint/, 2010.04.30 Release

Upvotes: 0

Views: 2904

Answers (1)

CinCout
CinCout

Reputation: 9619

This is how you can convert a std::string to BigInteger:

std::string s("3141592653589793238462643383279");
BigInteger f = stringToBigInteger(s);

Note that the method stringToBigInteger() is declared in BigIntegerUtils.hh.

This and many other sample usages of the library can be found here.

Upvotes: 4

Related Questions