Esempio n. 1
0
QString BinarytoInt(const QString &in)  //assumes only 1's and 0's in input, and that input is cleansed
{
    QString out;

    BigUnsigned pow(1);
    BigUnsigned val(0);

    for(int i=in.size()-1; i>=0; i--)
    {
        if(in[i].toAscii() == '1')
            val += pow;

        if(i>0)
            pow*=2;
    }


    std::string temp = bigUnsignedToString(val);
    out = QString::fromStdString(temp);

    return out;
}
Esempio n. 2
0
std::string bigIntegerToString(const BigInteger &x) {
	return (x.getSign() == BigInteger::negative)
		? (std::string("-") + bigUnsignedToString(x.getMagnitude()))
		: (bigUnsignedToString(x.getMagnitude()));
}