Rounding the Decimal to 1.00 and 0.10 in Android -


as title, how round decimal 1.00 if number 1.01,1.02,1.03,1.04 , round decimal 0.10 if number 0.05,0.06,0.07,0.08,0.09

you can try below code:

 private static void roundoff(double num) {     double intpart = (int) num;     double rondededoffnum = intpart+ math.round((num- intpart)*10)/10.0;     system.out.println(rondededoffnum); } 

Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -