Display full version of the post: limitations to a real

XPeter61
04.12.2010, 17:43

Peter Poeliejoe
04-12-10  17:21



When I type this (AutoLISP):

(+ 10000.8 2.4), the result is 10003.2, as expected.


However, when typed: (+ 100000.8 2.4), the result is

100003.0.
Is 100000 a magical border voor a real in AutoLISP? Any settings involved here?


Thanks in advance for any brain activity...Peter

HAWDesigner
13.12.2010, 22:45
All I can say is the system isn't perfect. LISP is a very old language and relied upon many many different factors that probably aren't in place with any of today's technology.Good Luck!!

CarlB
13.12.2010, 23:15
Lisp is limited by the same precision as is AutoCAD. It can store 16 digits in a number. To properly display numbers as internally calculated, use the "rtos" function.
 
For your example, you'll see the accurate decimals by setting precision to 1 or higher:
(rtos (+ 100000.0 3.2) 2 1)
 
where the "2" specifies decimal output, "1" is the precision, which can be 0 to 16.
 
With large numbers, the number of decimal places may be less that the precision; such as:
Command: (rtos 1234567890.0987654321 2 16)"1234567890.098765"
 

HAWDesigner
13.12.2010, 23:27
Nice!! Thanks Carl. I guess I learned my 'something new' today. I have a limited knowledge of LISP, but I do have a background in computer programming and love getting tidbits of info like this.

XPeter61
14.12.2010, 08:28
CarlB,
 
thanks for your answer.
I think this is exactly the information I was looking for.
 
Peter