java - precision error in output -


this question has answer here:

double x = 9/2 //x == 4.0? 

the output should 4.5, 4.0 mistake made?

9/2 <- without decimal specify int

9.0 / 2.0 <- double , should able 4.5


Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -