I am looking for Math.Abs(ulong,ulong) with return type ulong.
But it seems Microsoft only implemented it for long, int and so on.
Is there another fast way to do it?
Sorry, need to correct:
Math.Abs(ulong - ulong)
So it can get negative, and be out of the range of a long.
Unsigned long values are always positive, as they do not contain a sign. As such,
Math.Abswould make no sense forulong.Given your new question, you can use:
This will give you the difference between the two values, which is effectively the absolute value of the result you’d get by subtracting the two values as if they were signed.