Re: understanding some code
Re: understanding some code
What part of the code don't you understand?
Re: understanding some code
i'm completely new at programming so there is almost nothing i understand about it.
basically i only understand the last part, which is to save the result to a textfile.
this is the part that i want to have translated to a human language
Code:
public string CalculateOutputCode()
{
int[] numArray1 = new int[8];
int[] numArray2 = new int[8];
for (int index = 0; index < 8; ++index)
numArray1[index] = this.mivInputCode % this.Power(10, index + 1);
numArray2[0] = numArray1[0];
for (int pivNumber2 = 1; pivNumber2 < 8; ++pivNumber2)
numArray2[pivNumber2] = (numArray1[pivNumber2] - numArray1[pivNumber2 - 1]) / this.Power(10, pivNumber2);
this.mivOutputCode = 1 + numArray2[1] + this.Power(3, numArray2[2]) + numArray2[3] + this.Power(5, numArray2[4]) + this.Power(4, numArray2[5]) + this.Power(7, numArray2[6]) + this.Power(2, numArray2[7]);
return this.mivOutputCode.ToString();
}
private int Power(int pivNumber1, int pivNumber2)
{
int num = pivNumber1;
if (pivNumber2 == 0)
num = 1;
if (pivNumber2 == 1)
num = pivNumber1;
if (pivNumber2 > 1)
{
for (int index = 1; index < pivNumber2; ++index)
num *= pivNumber1;
}
return num;
i just want to know how the output is calculated. for example, when the input is 00636853 the result is 10796.
my goal is to make an app for my smartphone that can calculate this code so i don't have to open my laptop everytime just to generate a code when i have to log on to one of our machines.
Re: understanding some code
Please post the complete class and I'll give it a shot. I'm asking for the complete class because the code snippets you've included are missing the class constructor and I don't see anywhere the private Power() method is being called. So I need the entire class code to try to figure out what's going on.