How to customize the form of rounding
My question may seem simple, but still can not get something that works. I need to customize the Math.round rounding format or something to make it work as follows: If the number is 1.6 he should round to 1, if greater than or equal to 1.7 should round to 2.0 . And so to all other decimal results with # .6 The way I'm doing the 1.6 being rounded to 2 shall be rounded to 1. How can I do that? Thank you! Simply do this: double threshold = 0.7; Math.round(x - threshold + 0.5); You could write a method that takes a double variable as input and returns the integer based on the first digit after the