A double literal is cast to float instead of being written as a float literal

tx0/java:float-literal-caststrictwarningstyle

What it finds

(float) 0.5 writes a double and converts it, where 0.5f is the float itself.

Reported is a cast to float of a floating-point literal without a suffix. The fix writes the literal with f.

From the rule's source, float_literal_cast.rs.

Example from the rule's tests
class Floats {  float a = (float) 0.5;tx0 reports: 0.5f is the float itself  float b = 0.5f;  float c = (float) 0.5f;}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:float-literal-cast" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:float-literal-cast] reason="..."

tx0 explain tx0/java:float-literal-cast shows the same in the terminal. Found a false positive? Report it.