Why do I get exception
Unhandled exception at 0x00000001 in TestingCOA.exe: 0xC0000005: Access violation (parameters: 0x00000008).
when I try to work with a 4294967295 or higher number. On my machine sizeof
double is 8bytes
which should be able to handle and work with2^64 -1
number but it is generating exception for a 32 bit number, why is that?
int main()
{
double n,remainderA;
int AfterDecimal1[64],RemExponent1;
cout<< "Enter number
";
cin>> n;
remainderA=a-(int)a;
HandleFractionNumber(remainderA,AfterDecimal1,RemExponent1);
}
int HandleFractionNumber(double remainder,int (&Goku)[64],int &RemExponent)
{
int x=0;
for(int i=0;;i++)
{
remainder*=2;
if(remainder>1)
{
remainder-=1;
Goku[x]=1;
x++;
}
else
if(remainder<1)
{
Goku[x]=0;
x++;
}
if(remainder==1)
{
Goku[x]=1;
break;
}
RemExponent=x;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…