My Oracle Support Banner

How to Properly Specify Rounding Behavior for Decimals in Java SE 8 (Doc ID 2285184.1)

Last updated on NOVEMBER 15, 2020

Applies to:

Java SE JDK and JRE - Version 8 and later
Information in this document applies to any platform.

Goal

You might have a program that uses the decimalFormat class for rounding arbitrary decimal values.  The following sample code illustrates the technique:

 

Is this a bug in Java SE?  How can you get the correct rounding results expected?

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution
 Caution
 Sample Code


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.