I would expect System.out.println(13 / 31)
to print 0.419354838709677
.
It prints 0.0
. Why?
I would expect System.out.println(13 / 31)
to print 0.419354838709677
.
It prints 0.0
. Why?
because you are dividing an int with an int therefore the result will be an int
try
System.out.println(13.0 / 31)
or
System.out.println((float)13 / 31)