PDA

View Full Version : help sought on lisp file alteration.

diarmuid
4th Aug 2004, 05:04 pm
(setq ht1 (cdr (assoc 40 en3)))
(setq xdist (/ 12 7))
(setq dist (* xdist ht1))

the value xdist on the last line used to be 1.714

i added a new line (the middle line) and i wanted that line to be be assigned a value of 12 divided by 7 which is 1.714 reoccuring. i want it to be that accurate.

when i run the routine it only returns a value of 1. (xdist that is) i know if i put (/ 12.0000000 7) i know that will solve the problem, to a point. am correct in doing it this way.

Alternatively could i delete the middle line and re-writ the line:

(setq dist (* ((/ 12.000000 7)ht1)))

am i correct?

any takers?

Thanks

Diarmuid

Kate M
4th Aug 2004, 05:27 pm
I think that by entering "12" and "7" in your code, you're telling it to use integers, so the division would return "1" as you've experienced. Using "12." and "7.", though, indicates real numbers, and should give you the desired result.

(I haven't actually tried this, so let me know if it doesn't work.)

David Bethel
4th Aug 2004, 05:46 pm
Or you can use the (float) function

&#40;setq xdist &#40;/ &#40;float 12&#41; 7&#41;&#41;

&#40;setq a 12&#41;
&#40;setq xdist &#40;/ &#40;float a&#41; 7&#41;&#41;

It only needs 1 REAL to declare the results as a REAL

&#40;setq xdist &#40;/ 12. 7&#41;&#41;

-David

diarmuid
5th Aug 2004, 08:25 am
thanks guy's