Skip to content
Reference > Methods

percentDiff(a,b)

Definition

Double percentDiff(Number a, Number b)

Description

This method will use this formula, diff(a,b) / avg(a,b), to obtain the result. Returns null if either one is null, returns NaN if either is negative or if both are zero, otherwise follows formula.

Parameter Definition

Name Type Description
a Number first value, should be positive
b Number second value, should be positive

Examples

1
2
3
Double r1 = percentDiff(10,15); // r1 == 0.4
Double r2 = percentDiff(5,20); // r2 == 1.2
Double r3 = percentDiff(-4,30); // r3 == NaN