pi = pi + (negativeController * 4 / denominator);
The (negativeController * 4 / denominator)
expression results in an int
because both negativeController
and denominator
are int
. In other words, you're doing an integer division here which explains why you don't get the expected result.
Declare either (or both) of them as double
to force a floating-point division.