Author Topic: Division Precision  (Read 2404 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7531
Division Precision
« on: January 19, 2006, 02:12:40 PM »
Why is this rounding the answer down instead of putting the correct decimal place?

Code: [Select]
  (setq ss1 (ssget '((0 . "LWPOLYLINE") (8 . "0280-shrub-lateral"))))
  (setq ss1 (sslength ss1))
  (alert (rtos(/ ss1 30)2 2))

For example sslength of ss1 = 88. The number returned after being divided by 30 is 2.00 rather than 2.93?

Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Division Precision
« Reply #1 on: January 19, 2006, 02:24:33 PM »
If you divide by an intergers, then the returned value will be an interger, so changing one of the numbers to a real will return a real.
Change
Code: [Select]
(/ ss1 30)
to
Code: [Select]
(/ ss1 30.0)
And you should get what you want.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Division Precision
« Reply #2 on: January 19, 2006, 02:33:57 PM »
Thanks :). It's all those little things that kill me! :realmad:

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Division Precision
« Reply #3 on: January 19, 2006, 02:51:38 PM »
Thanks :). It's all those little things that kill me! :realmad:
You're welcome.  I hate learning those the hard way also.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.