Performs the subtraction of two long positive integers in the given base.

You're viewing an older version of this page (#230). View the current version.

View versions (1)

Interface

#include <codecogs/maths/combinatorics/arithmetic/subtract.h>

using namespace Maths::Combinatorics::Arithmetic;

This function calculates the subtraction of two long <em> positive </em> integers stored as character strings, in the given numerical base. The maximum number of digits of either of the numbers is only limited by the amount of memory available.

Example 1

#include <codecogs/maths/arithmetic/subtract.h>
#include <iostream>

int main()
{
  std::string a("232342353"), b("73452344"),
  c = Maths::Arithmetic::subtract(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
232342353 - 73452344 = 136670007

Parameters

a
the first number
b
the second number
base
Default value = 10

Returns

a character string corresponding to the difference of the given numbers

The first number needs to be greater than the second, otherwise the function will exit.

GPL Licence — free for non commercial use. See Licence details.

Interactive Calculator

a
b
base
Result