I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 2.79
sub units 0.00
+
0

multiply

viewed 2590 times and licensed 85 times
Performs the multiplication of two long positive integers in the given base.
Controller: CodeCogs

Interface

C++
Excel

Multiply

 
std::stringmultiplystd::stringa
std::stringb
intbase = 10 )
This function calculates the multiplication of two long <em> positive </em> integers stored as character strings, in the given numerical base. The maximum number of digits of either the numbers is only limited by the amount of memory available. The algorithm used is school multiplication and has time complexity where \inline  |a| is the length (number of digits) of a and \inline  |b| is the length of b.

Example:

#include <codecogs/maths/arithmetic/multiply.h>
#include <iostream>
 
int main()
{
  std::string a("77723445"), b("1236174734675"),
  c = Maths::Arithmetic::multiply(a, b, 8);
  std::cout << "The following is a base 8 operation" << std::endl;
  std::cout << a << " * " << b << " = " << c << std::endl;
  return 0;
}

Output:

The following is a base 8 operation
77723445 * 1236174734675 = 123525352137151621521

Parameters

athe first factor
bthe second factor
baseDefault value = 10

Returns

a character string corresponding to the multiplication of the given numbers

Authors

Anca Filibiu and Lucian Bentea (September 2005)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.