I have an array of integers that I need to convert to a single integer. Is there a function built into C++ that I can use to do so? If so, what is it called and how is it implemented?
If not, could someone please walk me through the logic of how that function would work?
1. string way: use a stringstream to convert first to a string by adding and so on.
2. math way: use your knowledge about p-adic representation of numbers
means:
sum(i = 0 to 15) { a_i * p^i } = number
and your a_i are your values in the array (a[i])
and p is in your case 10, because it is decimal base.
1 2 3
double total(0);
for (int i = 0; i < 16; i++)
total += a[i]*pow(10,i);
EDIT: wow, stop. why didnt it work? i just now realized your chunk of code. But you didnt use any code tags.. What's the error?