Tutorial: Page (1) of 2 - 12/26/01 Email this story to a friend. email article Print this page (Article printing at MyDmn.com).print page facebook

AutoLISP tip - Integer and real numbers

By Jos van Doorn
AutoLISP works with integers and reals. An integer can have a value between +32767 and -32768. Those are 16 bits values.

AutoLISP works with 32 bits values. So the value could be between +2,147,483,648 and -2,147,483,647. But the transfer to AutoCAD is restricted to 16 bits.


Reals contain a decimal point. A precision of 14 digits is used for reals. Although 14 digits are not always shown. Only six digits are shown.

Watch out now. Watch out when programming in AutoLISP. Suppose you're using a real number and not an integer. Then specify a real number.

Maybe you've got a line like this in your program:

(setq nr 10)

You want to number 10 to be a real. Than change that line. Change it to:

(setq nr 10.0)

Here's a simple program that shows where it can go wrong:

(defun dgtrd (an)
(* (/ an 180) pi)
)

(defun c:count ()
(setq a1 0)
(repeat 10
(setq a2 (dgtrd a1))
(princ " Degrees: ")
(princ a1)
(princ " Radians: ")
(princ a2)
(setq a1 (- a1 10))
)
(princ)
)
(c:count)

Page: 1 2 Next Page


Related Keywords:CAD, AutoLISP

HOT THREADS on DMN Forums
Content-type: text/html  Rss  Add to Google Reader or
Homepage    Add to My AOL  Add to Excite MIX  Subscribe in
NewsGator Online 
Real-Time - what users are saying - Right Now!

Our Privacy Policy --- @ Copyright, 2015 Digital Media Online, All Rights Reserved