Can anyone help me with this problem (how far a number is from another in either direction?)

46 Views Asked by At

This is Probably very easy for most of you... I need a formula which will tell me how far a number is from another in either direction? Higher or lower. Eg. The answer would be 1 if the numbers were 10 and 11 or 10 and 9. The answer would be 3 if the numbers were 10 and 13 or 10 and 7. etc

1

There are 1 best solutions below

0
On

Use absolute value $$D(a, b) = |a - b|$$