integer_division_in_float
Finds an integer division whose result is used as a float.
Category suspicious, warn by default.
#import "Basic";
main :: () {
done := 3;
total := 4;
ratio := cast(float) (done / total);
print("%\n", ratio);
}warning[integer_division_in_float]: integer division `done / total` is converted to a float: the remainder is lost first
--> example.jai:6:27
|
6 | ratio := cast(float) (done / total);
| ^^^^^^^^^^^^
|
help: divide as floats: `cast(float) done / total`
|
6 ~ ratio := cast(float) (cast(float) done / total);
|
= note: `integer_division_in_float` is `warn` by default#import "Basic";
main :: () {
done := 3;
total := 4;
ratio := cast(float) done / cast(float) total;
print("%\n", ratio);
}Operands are typed before the cast, so the integers divide first.