Division of integers rounds towards zero. You have to use a float for one of the parameters in order for the division to work as you intend (compiler treats it as a float operation instead of an integer operation).
ok tnx
btw I know this is not unity-specific I have just gotten accustomed to the Unity forums already
so how do I turn one of the to float? just add .0 or smth like that?
An integer division happens when you divide an integer by another integer. If that happens the result will be an integer again. So you can not get any fractional numbers as result. So something like 5/4 is an integer division and will result in the number 1 while the division 2/3 will result in 0. You need to use float literal values instead. As soon as one of the operands is a float, it would be a float division and the result would be a float. So do
int stat = Mathf.RoundToInt((Mathf.Pow(player.Str, (5f / 4f)) * (Mathf.Pow(player.Dex, (2f / 3f)) + 1f)) / 10f);
Not all f are necessary here, but when you work with floats, it’s best to use the proper literal value.
It needs to also have an f, so for instance 1.0f or just 1f, so it’s treated as a float instead of a double. Mathf.Pow expects floats. Integer types are automatically converted to float for the call, double is not.
A useful tip: make a general function for integer ratios that should evaluate as floating point. I do that all the time because you can’t make an integer division error by accident.
static public float ratio(int a, int b) => a / (float)b;
(As soon as one operand is explicitly cast to float, the other is converted automatically and the operation is inferred as floating point division. It also looks nicer in the user code, you don’t need to cast there, and you don’t need f suffix etc.)
Edit:
Obviously no need to do this when you’re working with literal values. This is more like a general approach for variables.
Edit2:
Also I’m astonished that no one made a joke out of your title typo
So, here’s another answer to your question
Edit3:
This is how I’d write your expression
var strTerm = pow(str, 5f/4f); // you could just write 1.25f but these divisions are
var dexTerm = 1f + pow(dex, 2f/3f); // converted to value constants in compile time anyway
int stat = roundToInt(strTerm * dexTerm / 10f);