arabian_albert - 10 months ago 94

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 Source

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

or if you want sign

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