Well I did what you told me I used a double int thing. Well ok double var_name. And well I had a user put in 2 numbers (the user was me) and then pick a operation. I only had + sence it was a test. But anyways I added to small numbers 2+2. And guess what it equalled. NOT 4! it was over 2000! I will give the code I used...
Code:#include <iostream.h> #include <conio.h> #include <windows.h> int main() { char operation; long double number_1; long double number_2; long double number_3; long double number_4; long double resault_1; long double resault_2; number_1 = 0; number_2 = 0; number_3 = 0; number_4 = 0; cout<<"Number 1: "; cin>>number_1; cout<<"Operator: "; cin>>operation; cout<<"Number 2: "; cin>>number_2; if(operation==1) resault_1=number_1+number_2; cout<<resault_1; getch(); return 0; }
I know how I pick the operation is wierd but like I said this is a test. You can try it and see the resaults if you want.
Edit: Why does it do that?
Edit Edit: It also does that if I take away the longs before the doubles.



LinkBack URL
About LinkBacks




