cadsterdyne Posted August 9, 2016 Posted August 9, 2016 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. Quote
rlx Posted August 9, 2016 Posted August 9, 2016 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 Quote
MURAl_KMD Posted August 9, 2016 Posted August 9, 2016 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) Quote
BIGAL Posted August 9, 2016 Posted August 9, 2016 my go (setq 60th (/ 1.0 60.0)) (+ 40.0 (+ (* 20.0 60th) (* 50.0 (* 60th 60th)))) Quote
cadsterdyne Posted August 9, 2016 Author Posted August 9, 2016 Aa Haaa...!!! I read that, now i remember..... Thanks a lot rlx and MURAl_KMD... Autolisp Noob alert...! Quote
cadsterdyne Posted August 9, 2016 Author Posted August 9, 2016 Thanks BIGAL that looks like some advanced level AutoLisping Quote
Bill Tillman Posted August 9, 2016 Posted August 9, 2016 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. Quote
Recommended Posts
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.