I might sound incredible what I’m experiencing right now but I have this code along another operations.
double mues1 = 0;
mues1 = (Math.pow((ab/100),2)*tam);
Where ab=4, tam=400.
This should give .64, but the variable keeps being 0.0, and it only changes it’s value if the operation is bigger than 1.
If I replace the math.pow with ^2, the variable becomes 800.0 no matter which value has ‘ab’.
Just to make clear, I’m debugging the code so I know how the value is.
I have restarted eclipse and my computer and it didn’t help.
The problem is that the variable
abis an integer and you are performing integer division.According to integer division,
4/100 = 0. To get the result0.04, declareabas a double.FYI, the caret character in Java performs a bitwise xor, so you probably don’t want to use that.