@marko_ribar wrote:
I explained in message 5 that OP needs to use real numbers if wanted to get correct result...
Yes -- it was posted while I was already writing Message 6. But I have a few other comments:
I wonder about that (if (equal ... test, which seems unnecessary. With real-number inputs, under what circumstances could it ever not be equal? And if there is such a circumstance, shouldn't there also be an 'else' expression notifying the User that something's amiss, rather than nothing at all being reported [as happened when I ran it with integer inputs]?
The precision number of 50 in the (rtos) function is serious overkill. AutoCAD can only keep track of 16 significant figures, so you will never get anywhere close to 50 decimal places returned by anything:
Command: (rtos 700 2 50)
"700.0000000000000"
[only 13 decimal places]
A lot of your variables are used only once, so it doesn't seem necessary to save them -- just figure them at the place where they're used. That's how my suggestion, which uses no variables added beyond the inputs except B2, boiled down to its essence without comments and line breaks, is no more than just:
(setq B2 (+ A2 (* (/ (float (- B1 A1)) (- C1 A1)) (- C2 A2))))
And if the (if (equal ... test is really not needed, the db2c2 variable is also not needed.
Kent Cooper, AIA