C
C#2y ago
CTJ

❔ ✅ Equation in code

I have thsese two equations, one is inverse of another. I managed to get orange equation to work but green one does not for some reason. Any Ideas what I did wrong?
public static int GetLevel(decimal XP)
{
double level = 4 * Math.Pow((double)XP, 0.2794) - 5;
level = Math.Floor(level);
return (int)level;
}

public static double GetXpForLevel(int level)
{
double XP = Math.Pow((level + 5) / 4, 5000 / 1397); //gives wrong output
return XP;
}
public static int GetLevel(decimal XP)
{
double level = 4 * Math.Pow((double)XP, 0.2794) - 5;
level = Math.Floor(level);
return (int)level;
}

public static double GetXpForLevel(int level)
{
double XP = Math.Pow((level + 5) / 4, 5000 / 1397); //gives wrong output
return XP;
}
5 Replies
ero
ero2y ago
Math.Pow((level + 5) / 4d, 5000d / 1397d);
CTJ
CTJ2y ago
That worked, thanks! On side question, what does d do?
ero
ero2y ago
makes the number a double
CTJ
CTJ2y ago
Oh okay thanks !close
Accord
Accord2y ago
Closed! Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.