Ok, here is my problem. This program runs flawlessly until i input a number bigger than 5 char long. If i do it just outputs "1."
But if i put an int that is 8 char long than it outputs a "3"
Please help
Code:switch(resp) { case 1: cout << "Binary - Decimal..." << endl; cout << "Enter the number needing converting:" << endl; cin >> num; val = (num / 100000000); if(val >= 1.0) { cout << "Has to be under 8 numbers long!" << endl; break; } else a= num % 10; if (a == 1) { x = x + 1; } cout << x << endl; num2 = num / 10; a= num2 % 10; if (a == 1) { x = x + 2; } cout << x << endl; num2 = num2 / 10; a= num2 % 10; if (a == 1) { x = x + 4; } cout << x << endl; num2 = num2 / 10; a= num2 % 10; if (a == 1) { x = x + 8; } cout << x << endl; num2 = num2 / 10; a= num2 % 10; if (a == 1) { x = x + 16; } cout << x << endl; num2 = num2 / 10; a= num2 % 10; if (a == 1) { x = x + 32; } cout << x << endl; num2 = num2 / 10; a= num2 % 10; if (a == 1) { x = x + 64; } cout << x << endl; num2 = num2 / 10; a= num2 % 10; if (a == 1) { x = x + 128; }



LinkBack URL
About LinkBacks



.