I wanna write code to show the value of 2 power -5,
if I do like this, it gives correct answer.
if(b<0)
{
for(int i=1;i<=-b;i++)
{
result *=1.0/a;
}
}
////////////////////////////////////////////////////////////////////////
But, if I do like this, it can't give correct answer, why?
I think both are same.
if(b<0)
{
for(int i=-b;i<=1;i++)
{
result *=1.0/a;
}
}
///////////////////////////////////////////////////////////
If b = 3, for example, the first for() loop runs 3 times: i = 1, i = 2, i = 3.
the second for() loop runs 5 times: i = -3, i = -2, i = -1, i = 0, i = 1.