arabian_albert - 1 year ago 112

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?

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

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

or if you want sign

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