Function not working properly

When i was testing a piece of a larger program, i tested this function and it doesn't work as it should.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <string>
#include <cmath>
#include "profile.h"
#include "Global.h"
using namespace std;
float calc_exp_need(int level);
int main(){
	player_level = 70;
	required_exp = calc_exp_need(player_level);//required exp is a float
	cout<<required_exp<<endl;//player level is unsigned __int8
	system("pause");

}
float calc_exp_need(int level){
	float exp;
	exp = ceil((5*(level^3))/3);
	return (exp);
}

When using the number 70, it gives me 115 as the required exp. When using a calculator, I get 571,666. If it matters at all, the variables player_level, required_exp and player_level are global.
^ is bitwise XOR, not exponentiation.

 
pow((float)level, 3.f)

Or faster: level*level*level. If you use this one, you'll need to change your dividend to 3.f, or you'll use integer division instead of floating point division.
Thanks, that fixed it.
Topic archived. No new replies allowed.