<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: String to Real Back to String Conversion Dilemma in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13412005#M1219</link>
    <description>&lt;P&gt;Thanks for trying but unfortunately the numerator may not always be 1 with the rest of the numbers that need to be accounted for so that would not work&lt;/P&gt;</description>
    <pubDate>Mon, 07 Apr 2025 07:11:51 GMT</pubDate>
    <dc:creator>paullimapa</dc:creator>
    <dc:date>2025-04-07T07:11:51Z</dc:date>
    <item>
      <title>String to Real Back to String Conversion Dilemma</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13410771#M1213</link>
      <description>&lt;P&gt;I'm trying to do a round trip with the following string values converting them to real and then back to string. But I'm having trouble with getting 3 of them to successfully get a round trip.&lt;/P&gt;&lt;P&gt;Here's my code:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(setvar dimzin 0)
; set text string list:
(setq txtlst (list "1/16" "1/20" "1/32" "1/40" "1/48" "1/64"))
; perform text string to real number conversion function:
(setq numlst (mapcar '(lambda (x) (distof x 2)) txtlst))
; AutoCAD correctly returns a unique # for each:
; (0.0625 0.05 0.03125 0.025 0.0208333 0.015625)
; perform real number back to text conversion function:
(setq n2tlst (mapcar '(lambda (x) (rtos x 4 6)) numlst))
; AutoCAD returns with 3 mismatches 1/20, 1/40 &amp;amp; 1/48:
; ("1/16\"" "3/64\"" "1/32\"" "1/32\"" "1/64\"" "1/64\"")&lt;/LI-CODE&gt;&lt;P&gt;How can I get back "&lt;STRONG&gt;1/20&lt;/STRONG&gt;" "&lt;STRONG&gt;1/40&lt;/STRONG&gt;" &amp;amp; "&lt;STRONG&gt;1/48&lt;/STRONG&gt;" ?&lt;/P&gt;&lt;P&gt;I've tried increasing the precision from &lt;STRONG&gt;6&lt;/STRONG&gt; to a higher # but that made no difference:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0.05&lt;/STRONG&gt; will not convert back to "&lt;STRONG&gt;1/20"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0.025&lt;/STRONG&gt; will not convert back to "&lt;STRONG&gt;1/40"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0.0208333&lt;/STRONG&gt; will not convert back to "&lt;STRONG&gt;1/48"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Apr 2025 00:13:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13410771#M1213</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-04-06T00:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: String to Real Back to String Conversion Dilemma</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13410802#M1214</link>
      <description>&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;(rtos)&lt;/STRONG&gt; &lt;/FONT&gt;in Architectural or Fractional mode can return strings with &lt;EM&gt;only power-of-2 denominators&lt;/EM&gt; -- the choices you get in the Precision setting in the UNITS dialog box's Length category:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kent1Cooper_0-1743899866090.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1486109i94FB6CDD17102879/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kent1Cooper_0-1743899866090.png" alt="Kent1Cooper_0-1743899866090.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If you do this only with &lt;EM&gt;the numerator always being &lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/EM&gt;, as in your examples, something could be worked out to take the inverse of the decimal value, and build the fraction text string with the 1 and the slash and that inverse, rounded off in a lot of cases.&amp;nbsp; Otherwise, I can imagine too much iffiness about the whole concept of precision if the denominator could be anything.at all.&amp;nbsp; Suppose you start with "153/1427."&amp;nbsp; That's going to turn into a decimal value, but how could&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt; (rtos)&lt;/STRONG&gt; &lt;/FONT&gt;know to dig down that deep for the precision, i.e. how could it know to calculate that numerator which would need to be based on&lt;EM&gt; knowing what the denominator is?&lt;/EM&gt;&amp;nbsp; What would the precision argument in the function look like?&lt;/P&gt;</description>
      <pubDate>Sun, 06 Apr 2025 00:53:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13410802#M1214</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2025-04-06T00:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: String to Real Back to String Conversion Dilemma</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13410832#M1215</link>
      <description>&lt;P&gt;Thanks for the feedback...the&amp;nbsp;&lt;EM&gt;power-of-2 denominators &lt;/EM&gt;is definitely the limitation encountered here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Apr 2025 02:11:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13410832#M1215</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-04-06T02:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: String to Real Back to String Conversion Dilemma</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13411674#M1216</link>
      <description>&lt;P&gt;Like Kent's suggestion maybe rebuild the string using strcat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;: (/ 1. 0.05)
20.0
: (/ 1. 0.0208333)
48.0000768001229
: (/ 1. 0.015625))
64.0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Apr 2025 00:27:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13411674#M1216</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2025-04-07T00:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: String to Real Back to String Conversion Dilemma</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13411778#M1217</link>
      <description>&lt;P&gt;what I ended up doing is since I have these given strings is to look for those real numbers.&lt;/P&gt;&lt;P&gt;So the condition statements when it encounters&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0.05&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;will return "&lt;STRONG&gt;1/20"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0.025&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;will return "&lt;STRONG&gt;1/40"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;0.0208333&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;will return "&lt;STRONG&gt;1/48"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;but for the rest will go through the rtos conversion returning other strings&lt;/P&gt;</description>
      <pubDate>Mon, 07 Apr 2025 02:39:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13411778#M1217</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-04-07T02:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: String to Real Back to String Conversion Dilemma</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13411994#M1218</link>
      <description>&lt;P&gt;MY $0.05&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(SETQ NUMLST '(0.0625 0.05 0.03125 0.025 0.0208333 0.015625))
(setq n2tlst (mapcar '(lambda (x)  (STRCAT "1/" (RTOS (/ 1. x) 2 0))) numlst))&lt;/LI-CODE&gt;&lt;P&gt;("1/16" "1/20" "1/32" "1/40" "1/48" "1/64")&lt;/P&gt;</description>
      <pubDate>Mon, 07 Apr 2025 07:07:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13411994#M1218</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2025-04-07T07:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: String to Real Back to String Conversion Dilemma</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13412005#M1219</link>
      <description>&lt;P&gt;Thanks for trying but unfortunately the numerator may not always be 1 with the rest of the numbers that need to be accounted for so that would not work&lt;/P&gt;</description>
      <pubDate>Mon, 07 Apr 2025 07:11:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13412005#M1219</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2025-04-07T07:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: String to Real Back to String Conversion Dilemma</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13413747#M1220</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1137264"&gt;@paullimapa&lt;/a&gt;&amp;nbsp;yeah woke up this morning and thought what about "3/64"&lt;/P&gt;</description>
      <pubDate>Mon, 07 Apr 2025 23:25:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/string-to-real-back-to-string-conversion-dilemma/m-p/13413747#M1220</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2025-04-07T23:25:21Z</dc:date>
    </item>
  </channel>
</rss>

