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:
- if
x = 6.001
return6
- if
x = 5.999
return6
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
Post a Comment