MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerAnimemes/comments/ed9l7t/java_breathing_first_form_implicit_conversion/fbidu93/?context=3
r/ProgrammerAnimemes • u/[deleted] • Dec 20 '19
14 comments sorted by
View all comments
Show parent comment
7
int to float is an implicit cast, but float to int isn't. The OP's code still compiles because the compound assignment x /= 1.0f; is lowered into x = (int) (x / 1.0f); by the compiler.
int
float
x /= 1.0f;
x = (int) (x / 1.0f);
View all comments
Show parent comment
7
u/ThePyroEagle λ Dec 21 '19
inttofloatis an implicit cast, butfloattointisn't. The OP's code still compiles because the compound assignmentx /= 1.0f;is lowered intox = (int) (x / 1.0f);by the compiler.