Simple Difference
Posted: Wed Dec 19, 2007 10:12 pm
A very simple little procedure to give you a result using the negation operator when a number is below 0.
Saves the need to search left to right or right to left depending which number is bigger so you can get on with other more important things...
Saves the need to search left to right or right to left depending which number is bigger so you can get on with other more important things...
Code: Select all
Procedure.l Difference(a.l,b.l)
Result.l=a-b ;e.g a=1,b=2 Result=-1
If Result<0
ProcedureReturn -Result ;e.g. --1 = +1
EndIf
ProcedureReturn Result
EndProcedure
; Test Difference()
Debug Difference(1,2)