Java PWM getPosition() integer division bug?

After much troubleshooting trying to figure out why Servo.get() was returning 0.0 for any servo position other than 1.0, I noticed the following code in edu.wpi.first.wpilibj.PWM:


public double getPosition() {
    int value = getRaw();
    if (value < getMinNegativePwm()) {
        return 0.0;
    } else if (value > getMaxPositivePwm()) {
        return 1.0;
    } else {
        return (value - getMinNegativePwm()) / getFullRangeScaleFactor();
    }
}

Notice the final return statement. value, getMinNegativePwm(), and getFullRangeScaleFactor() are all of type int. Would this not cause the integer division to truncate to 0 for any result less than 1? I checked the C++ version of the same function, and sure enough, the numerator and denominator of the fraction are cast to float before the division.

Please post a bug report at: http://firstforge.wpi.edu/sf/tracker/do/listArtifacts/projects.wpilib/tracker.wpilib_java_bugs

Thanks,
-Joe

I posted the bug report. Did I do everything correctly? Am I supposed to assign the bug to anyone in particular?

http://firstforge.wpi.edu/sf/go/artf1156?nav=1&_pagenum=1&returnUrlKey=1264738567324

Looks good to me. The right person isn’t in the list. :frowning: I’ll make sure he hears about it.

We’ve observed the same issue, hopefully first will put out a fix for this.