Function differenceFromFixed

Returns the difference from the initial value. Defaults to absolute difference.

const rel = differenceFromFixed(100);
rel(100); // 0
rel(150); // 50
rel(50); // 50

'numerical' gives sign:

const rel = differenceFromFixed(100, `numerical`);
rel(100); // 0
rel(150); // 50
rel(50); // -50

'relative' gives proportion to initial

const rel = differenceFromFixed(100, `relative`);
rel(100); // 0
rel(150); // 0.5
rel(10); // 0.90

Using 'relativeSigned', we get negative relative result when value is below the initial value.

Use differenceFromLast to compare against the last value, rather than the same fixed value.

  • Parameters

    Returns ((value: number) => number)

    Difference from initial value

      • (value): number
      • Parameters

        • value: number

        Returns number