-2

Currently I am having a speed bump with adding two different integers. For example

int i = 32;
int j = 50;
/* Add i and j together into 3250 */

What I thought was changing the integers into strings and add them together but that takes too much effort. Is there any other way?

JunitHelp
  • 53
  • 5

1 Answers1

0

The solution in the decimal system is:

int result = 100* i + j;

In case this should be generic you'll need the following algorithm:

int shift = 10;
while(j >= shift) {
    pow *= 10;
}
int result = i * pow + j;     
xenteros
  • 15,586
  • 12
  • 56
  • 91