Thanks again.
I've tried implementing the following code in Visual c++ 6:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <cmath>
int main(){
int binary, n;
double temp, total;
total =0;
cout << "Please enter the binary number: ";
cin >> binary;
n = floor(log10(binary)) + 1;
for(int i=1; i<=n; i++) {
temp = binary % (i * pow(10,i));
total = total + (temp * pow(2,i));
}
cout << "Decimal equivalent is: " << total;
return 0;
}
but I am getting the following error:
--------------------Configuration: 2_30a - Win32 Debug--------------------
Compiling...
2_30.cpp
C:\Documents and Settings\Hugh\My Documents\2_30a\2_30.cpp(24) : error C2297: '%' : illegal, right operand has type 'double'
Error executing cl.exe.
2_30.obj - 1 error(s), 0 warning(s)
How can I get round this should I convert reesult of power to type int?
or is there an overloaded version of % which works with type double?