About 50 results
Open links in new tab
  1. How to round a number to n decimal places in Java

    Sep 30, 2008 · What I would like is a method to convert a double to a string which rounds using the half-up method - i.e. if the decimal to be rounded is 5, it always rounds up to the next number. This is the …

  2. How to round integer in java - Stack Overflow

    Apr 25, 2011 · 29 I want to round the number 1732 to the nearest ten, hundred and thousand. I tried with Math round functions, but it was written only for float and double. How to do this for Integer? Is there …

  3. math - Java Round up Any Number - Stack Overflow

    I can't seem to find the answer I'm looking for regarding a simple question: how do I round up any number to the nearest int? For example, whenever the number is 0.2, 0.7, 0.2222, 0.4324, 0.99999 I …

  4. java - How do I round to the nearest ten? - Stack Overflow

    Oct 3, 2016 · How can I round a number to the nearest ten with no if statements? For example, 98 to 100.

  5. round up to 2 decimal places in java? - Stack Overflow

    Jul 28, 2012 · Decimal Format does not round off the last decimal value for any of its functions. The margin for the round off for all the functions is >5 but its supposed to be >4. Eg - 1.235 should round …

  6. java - Using Math.round to round to one decimal place? - Stack Overflow

    Mar 5, 2014 · The Math.round method returns a long (or an int if you pass in a float), and Java's integer division is the culprit. Cast it back to a double, or use a double literal when dividing by 10.

  7. How to round up and down numbers in Java - Stack Overflow

    Mar 4, 2016 · Division should round up/down to the nearest integer. In this example, 5/3 should equate to 2 since 5/3 = 1.666 which rounds up to 2. I have made a function which does computes the …

  8. java - How can I format a String number to have commas and round ...

    Sep 9, 2010 · String number = "1000500000.574" //assume my value will always be a String I want this to be a String with the value: 1,000,500,000.57 How can I format it as such?

  9. numbers - How to round *down* integers in Java? - Stack Overflow

    Nov 23, 2009 · I'd like to round integers down to their nearest 1000 in Java. So for example: 13,623 rounds to 13,000 18,999 rounds to 18,000 etc

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

    Jun 26, 2014 · How to round double to nearest whole number and return it as Integer Asked 11 years, 8 months ago Modified 2 years, 10 months ago Viewed 55k times