I\'m currently working on a simulation of the MIPS processor in C++ for a comp architecture class and having some problems converting from decimal numbers to binary (signed
I checked your code and couldn't find any error. Here is the code that i used...
#include
#include
using namespace std;
int main ()
{
int a=1111165117;
string binary ("");
int mask = 1;
for(int i = 0; i < 31; i++)
{
if((mask&a) >= 1)
binary = "1"+binary;
else
binary = "0"+binary;
mask<<=1;
}
cout<
Output will be 1001110001010110101111010011101. I you can run this on ideone