Code:(rtos arcButt 2 16)
I wrote a lisp and I get rounded results instead of actual real results. Because it is a long lisp I took out the part that create the rounded figure for me.
firstly, I wrote an external function for ArcSin and I call it here as asin:
(defun asin (x)
(ATAN X (SQRT (- 1 (* X X))))
)The result are:(defun c:test ()
(setq rad 4259.0623)
(setq angButt (* 2 (asin (/ (/ 8 2) rad))))
(setq angSinkless (* 2 (asin (/ (/ 4 2) rad))))
;Arc length variables
(setq arcButt (* angButt rad))
(setq arcSinkless (* angSinkless rad))
As you see I receive 8.0 and 4.0 the rounded figures.Command: test
How can I fix this?
Thanks for your reply,
I found the the rest of it on Help.
Also lisp does some funy things somtimes if you use integers v's reals in your code / x 2 may give a different answer to / x 2.0
by using "rtos" I will receive the real number as "string" so I cannot do other calculations using that number. I know "atof" to convert that to real number but it is not the best way.
Is there any way to force LISP to calculate with the highest precision which I think it is 16 digits?
I think Autolisp does the calculations up to 16 digits but when you ask it to print it rounds the figure.
Registered forum members do not see this ad.
The calculation is always done with maximum precision. When print as string, if you don't specify the number of decimals, the RTOS function will apply the value set by LUNITS system variable. This is the explanation of that rounding.
So, don’t have to be afraid, that affects only the display of string – internally it is retained and used with maximum precision.