Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Formatting double

807598May 19 2006 — edited May 19 2006
I need to format a double value without any precision

It can have 13 digits to the left of decimal and 6 digits right side of decimal.

I used
	public static String formatDouble(double dNumber) {
		DecimalFormat dcf = new DecimalFormat("##################0.000000");
		String sformattedDouble = dcf.format(dNumber);
		
		return sformattedDouble;
	}
Now the problem is that the DecimalFormat class uses ROUND_HALF_EVEN rounding, which I do not want to use.
Should I be using some other data type(like BigDecimal) instead as the numbers I am dealing with are pertaining to currency values so I can not use precision ?

Any suggestion will be great.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 16 2006
Added on May 19 2006
3 comments
193 views