PDA

View Full Version : Can't input numbers (with decimals) larger than 99999.9



Mike_R
2008-02-05, 03:33 PM
I'm using ACAD 2008 and for some reason, I've been having trouble with a rounding program I'm trying to write. I could've sworn I had one before but I can't find it now... Anyway, I'm trying to round decimal numbers off to the nearest 1/16, but if the numbers more than 100.03124, the result always comes out wrong. It's not rounded to exactly a 16th, as it should be. For example, 100.03125 should return 100.0625, but it returns 100.063. Doesn't seem like a big deal, but repeat that dozens of times and you could end up 1/4" off. In my field, that's not acceptable.

I've narrowed the problem down to this. If the number has more than 6 digits (including right of the decimal), AutoLISP or possibly AutoCAD, will truncate it to 6 digits, but only if theres a digit other than 0 behind the decimal. For example, 100.0625 becomes 100.063, 123456.7 becomes 123457.0, and 99999.9 becomes 100000.0.

This seems to be happening with any function that uses numbers.
(+ 123456.7 0) = 123457.0
(GETREAL) with an input of 123456.7 returns 123457.0
and so on.

The problem is, I can find no way of extending that limit to something more realistic... Anybody know how to fix?

rkmcswain
2008-02-05, 05:57 PM
Convert the real to a string if you need to display the answer.
If you only need the answer for internal calculations, don't worry about the display - all the decimal places are there (up to 15 significant digits)

Compare the output of:


_$ (+ 123456 0.78910)
123457.0


..to the output of..


_$ (rtos (+ 123456 0.78910) 2 16)
"123456.7891000000"

Mike_R
2008-02-05, 06:08 PM
:Oops: Yup, that was it...

Thanks again rkmcswain! :beer: