Author Topic: real numbers  (Read 1460 times)

0 Members and 1 Guest are viewing this topic.

jsr

  • Guest
real numbers
« on: July 25, 2010, 04:57:39 AM »
I have a lisp routine which reads point coordinates from excel sheet and inserts blocks at those points. All the points have 3 decimal places. For example

614332.785, 2619494.544

The routine works fine.

Now in another routine I get the base points of the blocks and compare them to their coordinates in the excel file they are not same but have slight difference for example the base point of the block inserted at above point would be reported by lisp as (614333.0, 261949e+006). What is the reason for this difference. How can I get the same exact value.

Similarly suppose their is a value 6123.494 stored in an excel cell when I extract that value (using vlisp) the system shows value of variant to be 6123.494 but when I call (valx-variant-value) the returned value becomes 6123 Why this .494 part is omitted. Please guide.

Thanks

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: real numbers
« Reply #1 on: July 25, 2010, 06:32:54 AM »
Here it goes;

Quote
(setq a 15.12345)
15.1235
(setq b (rtos a 2 3))
"15.123"
 (setq c (atof b))
15.123

Regards

Tharwat

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: real numbers
« Reply #2 on: July 25, 2010, 06:57:54 AM »
There are rounding errors when dealing with Doubles, but these should only be small and can be worked around using 'equal' for comparison with a small tolerance.