I need the perfect algorithm or C# function to calculate the difference (distance) between 2 decimal numbers.

For example the difference between:

**100** and **25** is **75**

**100** and **-25** is **125**

**-100** and **-115** is **15**

**-500** and **100** is **600**

Is there a C# function or a very elegant algorithm to calculate this or I have to go and handle every case separately with *if*s.

If there is such a function or algorithm, which one is it?

Licensed under: CC-BY-SA with attribution

Not affiliated with: Stack Overflow