AutoLISP subtration error

Cliff Davis

Usenet Archive
Joined
Jun 23, 2003
Messages
33
Reaction score
0
Using the following code where line1 is a 180d line, the idea is to reduce it to 0 in order to compare it another line that I will be doing the same thing to.

(setq *pi90* (* pi 0.5))

; to set the angle of the line assume 180d for my porpose (setq line1_angle (angle (dxf 10 (setq line1_list (entget line1))) (dxf 11 line1_list)))

(while (>= line1_angle *pi90*) (setq line1_angle (- line1_angle *pi90*)))

The problem is that "line1_angle" solves to
1.33227e-015
instead of 0.0.

Is there a reason that this is not solving to 0.00, is this a known issue. Is there some known fix for this? Thanks Cliff
 
Cliff Davis said:
The problem is that "line1_angle" solves to
1.33227e-015
instead of 0.0.

Is there a reason that this is not solving to 0.00

Yes. The reason is that no computer ever will have enough memory to store PI in full accuracy. And of course: no oldfashioned mathematician will ever have enough paper to write down PI to full accuracy.

There is no difference between computer based math and paper based math: comparing results of calculations which are based on real numbers like PI will always have limited accuracy.
is this a known issue

Yes, of course.
Is there some known fix for this?

Compare with EQUAL and a fuzzy value to give a bandwidth for the accuracy which will fullfill your needs. Something like (equal PI 3.14 0.01)

Tom Berger
 

Latest threads

Back
Top