Check out example codes for "java double to string fixed precision". It will help you in understanding the concepts better.

Code Example 1

Double toBeTruncated = new Double("3.5789055");

Double truncatedDouble = BigDecimal.valueOf(toBeTruncated)
    .setScale(3, RoundingMode.HALF_UP)
    .doubleValue();

Learn ReactJs, React Native from akashmittal.com