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 difference is between

```
x = Math.round(571.45732) / 10;

```

and

```
x = Math.round(571.45732);
x = x / 10;

```

Since `round(double)` returns a long, in the first case you divide a long by an int, giving the long 57. Converting back to double leads to 57.0. The second case is equivalent to

```
x = ((double)Math.round(571.45732)) / 10;

```

where a double is divided by an int, resulting in 57.1.
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.