I have a problem with this
System.out.print((9/5) * 3);
I expects the result 5.4 but it returns 3. Why is this happening?
9/5 is evaluated in integer arithmetic, so it's equal to 1.
Writing 9.0 / 5 * 3 is a common fix. (Promoting one of the coefficients in the term to a double forces the evaluation to take place in double precision floating point.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With