Hello just a quick question. I thought when i ran this that the double would hold more tha an int on a 64 bit system but at square 30 they both overflow. Did i do something wrong or is that the point were it gets to high for both of them and i have to split the board in half?
// Emperor Rice problem Date 8/26/15 E.Stephan
//This program will figure out the number of rice per square a person would get my doubling it.
#include <iostream>
usingnamespace std;
int main()
{
//initialize val ints then doubles
longint oldRice = 0;
longint rice =1;
double oldRice2 =0.0;
double rice2=1.0;
//set up chess square loop
for (int i=1;i<=64;i++)
{
if (i == 1) //if on square 1
{
oldRice=rice;
oldRice2=rice2;
cout << "\nYou have " << rice << " rice at square "<< i <<"\n";
}
else //if square is higher than 1 till then do this to end of the board.
{
rice=oldRice * 2;
cout<<"\nYou have " << rice <<" rice at square " << i <<"with int only \n";
oldRice=rice;
rice2=oldRice2 *2;
cout <<"\nYou have " << rice2 <<" rice at square " << i<< " with double int \n";
oldRice2=rice2;
}
}
return 0;
}