java - How to round double to nearest whole number and return it as Integer -


let suppose have double x. return nearest whole number of x. example:

  1. if x = 6.001 return 6
  2. if x = 5.999 return 6

i suppose should use math.ceil , math.floor functions. don't know how return nearest whole number...

for example, seems want use math.rint(). return closest integer value given double.

int valuex = (int) math.rint(x); int valuey = (int) math.rint(y);    

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -