I have the following two calculation using Math.round(...):

```
double x = 0.57145732;
x = x * 100;
x = Math.round(x * 10);
x = x / 10;

```

If I now print the value of x it will show me: 57.1.

```
double x = 0.57145732;
x = (Math.round((x * 100) * 10)) / 10;
// x = (Math.round(x * 1000)) / 10; //Also gives me 57.0.

```

If I now print the value of x it will show me: 57.0.

Why is there this difference in the outcome?
['https://Stackoverflow.com/questions/39326512', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/587261/']
The reason of the difference is that in the second formula you're making a division of two integer. in order to have the same result you have to add a cast to double:

```
double x = 0.57145732;
x = (double)(Math.round((x * 100) * 10)) / 10;

```
This because Math.round() returns an int. If you do this step-by-step (as in the first example), you assign the result of Math.round() to a float value. The following calculation uses then a float division.

In the second example, you let the JVM decide which types to use (and it uses an integer division as the intermediate step). This is why the precision gets lost.