casting - How can I convert float to integer in Java -


this question has answer here:

i need convert float number integer.

can java automatically convert float number integers? if so, normal rounding rules apply (e.g. 3.4 gets converted 3, 3.6 gets converted 4)?

you have in math library function round(float a) it's round float nearest whole number.

int val = math.round(3.6); \\ val = 4 int val2 = math.round(3.4); \\ val2 = 3 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -