# How would you round a double value to certain decimal Precision and Scale ?

By | November 26, 2019

In this post we will discuss about one of the basic  java interview question and question is that How would you round a double value to certain decimal Precision and Scale ?

First of all let us understand what’s the difference between Precision and Scale.

Precision represent total number of digits (or significant digits) of a real number and Scale specifies number of digits after decimal place
For example, 91.763 has precision of 5 and scale of 3

No body wants to loose the precision value of the number as it will change the value by large amount. If you still  willing  to loose the precision simply you can divide the number by 10 to the power precision.
There are several ways in Java to round the double value to certain scale, as  shown in the below example

Client program:

Output:

8754.33
8754.33
8754.33

You may also like:

That’s all about How would you round a double value to certain decimal Precision and Scale ?
If you have any feedback or suggestion please feel free to drop in blow comment box.