operator+

Function


friend BigInteger operator + ( const BigInteger& val1, const BigInteger& val2 );

Return a BigInteger object with value = val1 + val2.

Parameters

Two BigInteger objects val1 and val2.

Return value

A BigInteger object with value = val1 + val2.

Example

#include <iostream> 
#include <string>
#include "HKUAL_BigInteger.h"
using namespace std;
using namespace HKUAL;

int main() {
    BigInteger bigInt1( "10000" );
    BigInteger bigInt2( "20000" );
    BigInteger bigInt = bigInt1 + bigInt2;
    cout << "bigInt = " << bigInt << endl;
    return( 0 );
}

Output

bigInt = 30000

Time Complexity

, for n1, n2 is number of digits of val1, val2.

© The University of Hong Kong Algorithms Library - hkual@cs.hku.hk