+ 1
Java Challenge Fault
The Answer of the following Code pretends to be 12.0: x = 5 y = x * 2 z = x / 2 + y; System.out.println(z); The Answer should be 12,5!
4 Réponses
+ 6
it depends on what data type is used, if it's a floating point data type will definitely be 12.5 else if it's an integer then it's a two way thing on how the language handles its decimal, if .5 is round up to 0 or 1, in this case it's round up to 0, that's why you get 12.0
+ 2
Thank you that helped me alot to make progress in Java👍.
+ 1
Are integers always rounded down?