IntFloatConversion
Conversion from int to float may lose precision; use an explicit cast to float if this was intentional

Severity
WARNING

The problem

Implicit conversions from int to float may lose precision when when calling methods with overloads that accept bothfloat and double.

For example, Math.scalb has overloads Math.scalb(float, int) and Math.scalb(double, int).

When passing an int as the first argument, Math.scalb(float, int) will be selected. If the result of Math.scalb(float, int) is then used as a double, this may result in a loss of precision.

To avoid this, an explicit cast to double can be used to call the Match.scalb(double, int) overload:

int x = ...
int y = ...
double f = Math.scalb((double) x, 2);

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("IntFloatConversion") to the enclosing element.