1. ## Rounded figures!

Registered forum members do not see this ad.

Hi All,

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))))
)
(defun c:test ()
;Angle variables
(setq angButt (* 2 (asin (/ (/ 8 2) rad))))
(setq angSinkless (* 2 (asin (/ (/ 4 2) rad))))

(print angButt)
(print angSinkless)

;Arc length variables

(print arcButt)
(print arcSinkless)

(princ)
)
The result are:

Command: test
0.00187835
0.000939174
8.0
4.0
Command:
As you see I receive 8.0 and 4.0 the rounded figures.
How can I fix this?

2. Code:
`(rtos arcButt 2 16)`

I found the the rest of it on Help.

Cheers

4. 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

5. problem!!!

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?

6. I think Autolisp does the calculations up to 16 digits but when you ask it to print it rounds the figure.

7. 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.

Regards,
Mircea

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts