Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Jesse Black   on Apr 12 In Java Category.

  
Question Answered By: Liam Bouchard   on Apr 12

while this is an interesting way to do rounding, it's a *tad* inefficient.
It's as if you're reinventing the wheel by making one the size of a house. If
you want to round just use DecimalFormat:

import java.text.DecimalFormat;
public class Rounding {
public static void main(String[] args) {
DecimalFormat df = new DecimalFormat("#.00");
double d = 3.12345678901;
System.out.println(df.format(d));
}
}

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Rouning with double or float Or get search suggestion and latest updates.


Tagged: