<!--
{
  "documentType" : "article",
  "framework" : "AppStoreConnectAPI",
  "identifier" : "/documentation/AppStoreConnectAPI/computing-numeric-differences",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Computing numeric differences"
}
-->

# Computing numeric differences

Return the absolute difference between the maximum and minimum numerical values in an array.

## Discussion

Use the `diff()` function in the expression of a matchmaking rule to compute the greatest difference between two or more values. For example, `diff([ `4`, `3`, `2`, `1` ])` returns `3`, and  `diff([ `50`, `19`, `21`, `61` ]` returns `42`.

### Declaration

```other
number diff(array[number] $values)
```

### Parameters

-`values`: An array that contains the numeric values to compare.

### Return value

The absolute difference between the maximum and minimum items in the `values` array.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)