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;

```
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.