Inspectopedia Help

Implicit numeric conversion

Reports implicit conversion between numeric types.

Implicit numeric conversion is not a problem in itself but, if unexpected, may cause difficulties when tracing bugs.

Example:

double m(int i) { return i * 10; }

After the quick-fix is applied:

double m(int i) { return (double) (i * 10); }

Configure the inspection:

  • Use the Ignore widening conversions option to ignore implicit conversion that cannot result in data loss (for example, int->long).

  • Use the Ignore conversions from and to 'char' option to ignore conversion from and to char. The inspection will still report conversion from and to floating-point numbers.

  • Use the Ignore conversion from constants and literals to make the inspection ignore conversion from literals and compile-time constants.

Inspection options

Option

Type

Default

Ignore widening conversions

Checkbox

false

Ignore conversions from and to 'char'

Checkbox

false

Ignore conversions from constants and literals

Checkbox

false

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Java, 233.SNAPSHOT

Last modified: 13 July 2023