Author Topic: Decimal Place  (Read 1240 times)

0 Members and 1 Guest are viewing this topic.

MeasureUp

  • Bull Frog
  • Posts: 462
Decimal Place
« on: July 31, 2017, 08:35:26 PM »
I have a local variable "number1".
(setq number1 (getreal "\n\nGet Number: "))

I'd like to convert it to a string with 5 decimal digits (i.e. xxx.ddddd and xxx can be any number, no digit places limit)
The string I'd like to get is these formats:
"XXX.00000", if the input number is XXX. (In this case the input is an integer.)
"XXX.d0000", if the input number is XXX.d
"XXX.dd000", if the input number is XXX.dd
"XXX.ddd00", if the input number is XXX.ddd
"XXX.dddd0", if the input number is XXX.dddd
"XXX.ddddd", if the input number is XXX.ddddd

Thanks in advance.




Jeff_M

  • King Gator
  • Posts: 4095
  • C3D user & customizer
Re: Decimal Place
« Reply #1 on: August 01, 2017, 02:08:06 AM »
(rtos number1 2 5)

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Decimal Place
« Reply #2 on: August 01, 2017, 02:19:28 AM »
HaHaHa, how silly I am.
Need a day of sleep!

Thanks for pointing it out.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Decimal Place
« Reply #3 on: August 01, 2017, 08:15:43 AM »
Also beware of the effect of DIMZIN - I describe this issue here.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Decimal Place
« Reply #4 on: August 01, 2017, 07:51:10 PM »
Thank you Lee for the valuable info.  :laugh:

I have this issue before but could not figure it out.
Now I know it is caused by the value of DIMZIN is set to.