Using the abs function with the subtraction function doesn't seem like a good idea to me.
Command: (abs (- 7 3))
4
Command: (abs (- 3 7))
4
Command: (abs (- 3 -7))
10 < duh...
Maybe something like this which always returns the same answer, a positive value, regardless of negative/positive values. Also regardless of the order in which the arguments are presented.
(defun AbsSubtract (v1 v2)
(setq v1 (abs v1) v2 (abs v2))
(if (> v1 v2)
(- v1 v2)
(- v2 v1)
)
)
Command: (AbsSubtract 3 -7)
4
The basic idea: don't ask an arithmetic function to return a false answer. Rather condition the arguments first.
Joe Burke
"rdi" <rdi!@!writeme.com> wrote:
;subtract v2 from v1 and
;return positive value
(defun subpos(v1 v2)
(abs(- v1 v2))
)
(subpos 100 250) ;returns 150
(subpos 100 75); returns 25