Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Junilu Lacar wrote:No, it's not a bug. It's specified in the JLS here http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.26.2
Always say the TRUTH only
Junilu Lacar wrote:@Les see the JLS section I cited for the explanation. Compound assignment statements of the form op= have an implicit cast to the type of the variable being assigned to.
Always say the TRUTH only
Prosenjit Banerjee wrote:
I have understood the rule. But what can be the motivation behind it? I mean, if there is a possibility of some data to be lost if the programmer is not very careful, does not that go against the motto of Java?
science belief, great bioscience!
Whom are you accusing of carelessness?drac yang wrote:. . . considering the probability of such sort of carelessness, . . .
Prosenjit Banerjee wrote:I have understood the rule. But what can be the motivation behind it? I mean, if there is a possibility of some data to be lost if the programmer is not very careful, does not that go against the motto of Java?
OCAJP 7
No, it doesn't. It follows the rules. The rules of integer division were fixed before I was born, and you need to know them. It is no good forgetting the rules and then blaming the javac tool for remembering them. Look at this code:-You can use the javap tool to view the bytecode:-Dana Ucaed wrote:The compiler does things stealthily.
I shall leave you to work out which rule it is that means neither 1 nor 3 appears in that bytecode, only 0 in lines 4‑5.javac DivisionDemo.java
javap -c DivisionDemo
Don't get me started about those stupid light bulbs. |