<?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: Division by Integer in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047179#M134385</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why doesn't&amp;nbsp;division by integer&amp;nbsp; work in lisp? ....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just so you know....&amp;nbsp; Division by integer &lt;EM&gt;does&lt;/EM&gt; work and&amp;nbsp;returns a non-integer&amp;nbsp;result, if the &lt;EM&gt;first&lt;/EM&gt; number argument is a real number.&amp;nbsp; The real number doesn't need to be the divisor [second (or subsequent) number argument] -- it can be &lt;EM&gt;any&lt;/EM&gt; of the numbers involved.&amp;nbsp; It's only if &lt;EM&gt;all numbers involved are integers&lt;/EM&gt; that it returns an integer result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree that&amp;nbsp;Help&amp;nbsp;should be explicit about this.&amp;nbsp; The example with two integer arguments is something that divides equally, which doesn't make that clear.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Feb 2016 12:43:19 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2016-02-19T12:43:19Z</dc:date>
    <item>
      <title>Division by Integer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6046829#M134382</link>
      <description>&lt;P&gt;Being a relative newcomer to lisp, I didn't know some of the basic flaws in the lisp language. I've just been writing a piece of code that needed the inverse of a&amp;nbsp;number within it. Pretty simple I thought. But:&lt;/P&gt;&lt;PRE&gt;(/ 1 20)
Returns 0&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However turn the number unnecessarily into a real number then it works just fine:&lt;/P&gt;&lt;PRE&gt;(/ 1 20.0)
or
(/ 1 (float 20))
Return 0.05&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Undoubtedly experianced lispers all know this but it doesn't exactly jump off the page of the 'AutoLISP Functions By Name' site. In fact it says:&lt;/P&gt;&lt;P&gt;(/ [number number ...])&lt;/P&gt;&lt;P&gt;&lt;FONT color="#339966"&gt;number&amp;nbsp; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#339966"&gt;Type: &lt;U&gt;Integer&lt;/U&gt; or Real&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why doesn't&amp;nbsp;division by integer&amp;nbsp; work in lisp? Why hasn't AutoDesk fixed this basic mathematical function that even an early 1970's LED calculator was capable of?&lt;/P&gt;&lt;P&gt;Are&amp;nbsp;there any other daft shortcomings within lisp thst anybody knows of?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rant over&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 07:33:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6046829#M134382</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-02-19T07:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Division by Integer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6046866#M134383</link>
      <description>It's not a bug or some weakness of AutoLisp. Sometimes, when you deal with integers only, it is of real use.&lt;BR /&gt;You just need to be aware of this and use the proper transformation when you need it. Either (/ 4 (float 5)) and (/ 4 1.0 5) works.&lt;BR /&gt;&lt;BR /&gt;PS. Other Lisp variations uses 2 different functions to return an integer or a floating-point number: "/" and "div"</description>
      <pubDate>Fri, 19 Feb 2016 08:11:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6046866#M134383</guid>
      <dc:creator>phanaem</dc:creator>
      <dc:date>2016-02-19T08:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Division by Integer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047065#M134384</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;(/ integer integer) = &lt;STRONG&gt;integer&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if at least one of them is a real, then returns a real.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just always use &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;(/ a 20.)&lt;/FONT&gt;&lt;/STRONG&gt; to make sure that integer does not surprise me... (if I am not sure if &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;'a'&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;is an integer or real.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 11:01:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047065#M134384</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2016-02-19T11:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Division by Integer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047179#M134385</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;....&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why doesn't&amp;nbsp;division by integer&amp;nbsp; work in lisp? ....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just so you know....&amp;nbsp; Division by integer &lt;EM&gt;does&lt;/EM&gt; work and&amp;nbsp;returns a non-integer&amp;nbsp;result, if the &lt;EM&gt;first&lt;/EM&gt; number argument is a real number.&amp;nbsp; The real number doesn't need to be the divisor [second (or subsequent) number argument] -- it can be &lt;EM&gt;any&lt;/EM&gt; of the numbers involved.&amp;nbsp; It's only if &lt;EM&gt;all numbers involved are integers&lt;/EM&gt; that it returns an integer result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree that&amp;nbsp;Help&amp;nbsp;should be explicit about this.&amp;nbsp; The example with two integer arguments is something that divides equally, which doesn't make that clear.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 12:43:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047179#M134385</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-02-19T12:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Division by Integer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047581#M134386</link>
      <description>&lt;P&gt;BeekeeCZ wrote:&lt;/P&gt;&lt;P&gt;'I just always use (/ a 20.)'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And Kent wrote:&lt;/P&gt;&lt;P&gt;'....if the first number argument is a real number'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But why should we need to? Imagine the fuss if Microsoft had coded Excel like that, or Casio their calclators !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'God grant me the serentity....'&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 15:33:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047581#M134386</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-02-19T15:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Division by Integer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047624#M134387</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1779365"&gt;@ВeekeeCZ&lt;/a&gt; wrote:&lt;/P&gt;
&lt;P&gt;'I just always use (/ a 20.)'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;@Anonymous Kent wrote:&lt;/P&gt;
&lt;P&gt;'....if the first number argument is a real number'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why should we need to? ....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For myself, I don't think I would ever need the integer-only operation, either, but&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/314908"&gt;@phanaem&lt;/a&gt;&amp;nbsp;may be able to answer that question with&amp;nbsp;some&amp;nbsp;enlightenment about&amp;nbsp;a situation meeting their description in the first line in Post 2.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 16:01:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047624#M134387</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-02-19T16:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Division by Integer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047801#M134388</link>
      <description>&lt;P&gt;As with the others, I don't see the problem here. &amp;nbsp;That the division operator uses promotion rules to go from integer to real is pretty obvious in the user help file examples and the supplemental links about number handling are also helpful. &lt;A href="http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-E9E70DA9-6048-470D-B899-239B097671D2" target="_self"&gt;See the 2016 help docs here.&lt;/A&gt;&amp;nbsp; Now compare that coverage with the 2&lt;A href="http://docs.autodesk.com/ACD/2011/ENU/filesALR/WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6af2.htm" target="_self"&gt;011 help on the division function&amp;nbsp;here.&lt;/A&gt;&amp;nbsp; This is a significant improvement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Help files are not designed to substitute for either textbooks, classes, or programming experience. &amp;nbsp;Specify the domain for your arguments and test all functions for the specified domain until you are certain of what the return values will be.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 17:09:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6047801#M134388</guid>
      <dc:creator>dbroad</dc:creator>
      <dc:date>2016-02-19T17:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Division by Integer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6048325#M134389</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/69526"&gt;@Kent1Cooper&lt;/a&gt; wrote:&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;For myself, I don't think I would ever need the integer-only operation, either, but&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/314908"&gt;@phanaem&lt;/a&gt;&amp;nbsp;may be able to answer that question with&amp;nbsp;some&amp;nbsp;enlightenment about&amp;nbsp;a situation meeting their description in the first line in Post 2.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, I have some example, but it has nothing to do with the AutoCAD, is pure mathematic.&lt;/P&gt;&lt;P&gt;Some time ago I've made an entire set of operations for big numbers. I mean really big integers..&lt;/P&gt;&lt;P&gt;2^200&lt;/P&gt;&lt;P&gt;_$ (expo '(2) 200)&lt;/P&gt;&lt;P&gt;(1 6 0 6 9 3 8 0 4 4 2 5 8 9 9 0 2 7 5 5 4 1 9 6 2 0 9 2 3 4 1 1 6 2 6 0 2 5 2 2 2 0 2 9 9 3 7 8 2 7 9 2 8 3 5 3 0 1 3 7 6)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A comparison between integer and real numbers:&lt;/P&gt;&lt;P&gt;_$ (expo '(2) 3)&lt;BR /&gt;(8)&lt;BR /&gt;_$ (expo '(2.0) 3)&lt;BR /&gt;(0.16 1.6 8.0)&lt;/P&gt;&lt;P&gt;I guess I could acomplish the same result with a little extra work, but integers' division behavior helps alot.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2016 21:14:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6048325#M134389</guid>
      <dc:creator>phanaem</dc:creator>
      <dc:date>2016-02-19T21:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: Division by Integer</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6050119#M134390</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You've hit one of the historical oddities in Lisp, from long before Autodesk got mixed in it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The cultural idea here is that you don't get automatic floating-point contagion, you have to ask for it. If you are doing serious integer mathematics with exact numbers, you really don't want the system to change to floating point in the middle of a calculation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- In Common Lisp you also have rational numbers, so there the integer division won't truncate, it just returns a ratio.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.lispworks.com/documentation/HyperSpec/Body/f_sl.htm," target="_blank"&gt;http://www.lispworks.com/documentation/HyperSpec/Body/f_sl.htm,&lt;/A&gt; and alternatives:&amp;nbsp;&lt;A href="http://www.lispworks.com/documentation/HyperSpec/Body/f_floorc.htm#floor" target="_blank"&gt;http://www.lispworks.com/documentation/HyperSpec/Body/f_floorc.htm#floor&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In addition to the general oddities of the Lisp language family, you also need to beware some of the things AutoLISP does differently than other Lisps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Autolisp:&lt;BR /&gt;_$ (&amp;lt; nil 5)&lt;BR /&gt;T&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lispworks:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CL-USER 5 &amp;gt; (&amp;lt; nil 5)&lt;/P&gt;&lt;P&gt;Arithmetic error in &amp;lt; of (NIL 5): Arguments must be real numbers.&lt;BR /&gt;[Condition of type CONDITIONS::ARITHMETIC-TYPE-ERROR-WITH-MESSAGE]&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>Mon, 22 Feb 2016 10:06:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/division-by-integer/m-p/6050119#M134390</guid>
      <dc:creator>martti.halminen</dc:creator>
      <dc:date>2016-02-22T10:06:53Z</dc:date>
    </item>
  </channel>
</rss>

