Jump to content

Recommended Posts

Posted

Hi Forum.

 

By general math calculation on calculator this expression

40 + (20 * 1/60) + (50 * 1/60 * 1/60) = 40.34722222

 

here is the same thing i am trying to do in auto cad command line.

 

(+ 40 (+ (* 20 (/ 1 60)) (* 50(* (/ 1 60 ) (/ 1 60)))))

and it returns 40 as the answer am i missing something.

Posted

Yes your missing something :-)

 

 

since you only use integers , lisp will only return integers. Try using (/ 1.0 60) or (/ 1 60) and see what happens

 

 

gr. Rlx

Posted

hi

Have a look

(+ 40 (+ (* 20 (/ 1.0 60)) (* 50(* (/ 1.0 60 ) (/ 1.0 60)))))
(rtos (+ 40 (+ (* 20 (/ 1.0 60)) (* 50(* (/ 1.0 60 ) (/ 1.0 60))))) 2)

Posted

my go

 

(setq 60th (/ 1.0 60.0))
(+ 40.0 (+ (* 20.0 60th) (* 50.0 (* 60th 60th))))

Posted

:facepalm: Aa Haaa...!!!

I read that, now i remember..... Thanks a lot rlx and MURAl_KMD...

 

Autolisp Noob alert...!:D

Posted
:o Thanks BIGAL that looks like some advanced level AutoLisping :notworthy:
Posted

The above advice is spot on. I use many large programs and in an attempt to save kilobytes, and typing I use

(+ 40. (+ (* 20. (/ 1 60.)) (* 50. (* (/ 1. 60 ) (/ 1. 60)))))

Not too much savings and these days, HD space and memory runs in the Gigabytes, but it's just been my style. This only works if your numbers are whole. Also, I've found that you can omit the .0 on some of the numbers. As long as at least one of them has a decimal point LISP will perform floating point arithmetic on the equation for you.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...