arabian_albert - 3 months ago 34

Java Question

I have 2 doubles.

`double a = 100.00`

double b = 99.00

The difference here is that b exhibits a 1% decrease with respect to a.

How can I calculate something similar in Java?

Answer

```
double percDiff = Math.abs( a - b ) / a * 100;
```

or if you want sign

```
double percDiff = (b - a) / a * 100;
```