I have an odd issue with an old lisp routine. We’ve been using this routine from the year 0, and somehow an error snuck in so it doesn’t work as it should. I know for a fact it once used to work as it should, I never touched it or modified it, and now something goes wrong somewhere.
It’s a routine that sets a few parameters, and will then draw a spring with a particular diameter. The wire diameter should be 27mm (radius 13.5mm), but for some reason, the end result is a spring with a diameter 26mm. Something is causing that number to be rounded down to 26mm (=radius 13mm).
Now, where it gets really weird is this: say if I enter Diameter 29mm, it rounds down to 28mm. Ok, sounds like that can be expected. However, if I go in and say Diameter 27.0001mm, it will go and draw me a circle with a diameter 27.0001mm. No rounding up or down this time. I can cheat the system by telling it to draw a circle with diameter 27.00000000001mm, and it will give me exactly what I want.
Am I dealing with a bug here, or can someone tell from looking at the code that the problem is in there? I'd be curious if others can reproduce this same problem. I'm running Acad 2010, and unfortunately i cannot test it on a previous version myself, because I suspect it's not the code, but Acad 2010 causing it.
I'ts not a bug, it's not due to 2010 behavior and I can't believe it worked fine one time.
This is due to the division (/) lISP operator implementation which never changed.
With LISP arithmetic operators (+, -, *, /, rem, expt) if all arguments ar integers, the result will be an integer too. If almost one argument is a real number the result will be a real number.
You are right, someone must have changed it somewhere along the line then. It just took quite some time for someone here to notice! Luckily it's a little used feature, rather than a lot of incorrect springs generated in many drawings.
Thanks for your help gile, much appreciated I never would have figured this out. I thought a number had to be defined as an integer for it to behave as one.