<?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: Calculating double in python results in integer, while AM calc'ing produces decim in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/calculating-double-in-python-results-in-integer/m-p/661392#M22022</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great, thank you Chris and Dan for your replies and solutions.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Janice Poehlman&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wisconsin DNR&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.s. the application is drive-time analysis for recreation land profiles and guidance for funding priorities.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Jul 2010 13:23:21 GMT</pubDate>
    <dc:creator>JanicePoehlman</dc:creator>
    <dc:date>2010-07-27T13:23:21Z</dc:date>
    <item>
      <title>Calculating double in python results in integer, while AM calc'ing produces decimals</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculating-double-in-python-results-in-integer/m-p/661389#M22019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm running a calculation that produces decimals while using the AM field calculator but results in integers while using python.&amp;nbsp; Can you help?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The AM field calculator expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;minutes = [length_mile] *60 / [speed_limit]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The python expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.calculatefield_management ("highway", "minutes", "!length_mile!*60/!minutes!","PYTHON")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The field to be calculated is added using gp.addfield_management:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.addfield_management (filename, "minutes", "double")&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;After my python code produced numbers rounded to the integer, I double-checked using the field calculator and the result included the decimals.&amp;nbsp; I need the decimals.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone help with my programming oversight?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Janice Poehlman&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wisconsin DNR&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jul 2010 21:05:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculating-double-in-python-results-in-integer/m-p/661389#M22019</guid>
      <dc:creator>JanicePoehlman</dc:creator>
      <dc:date>2010-07-26T21:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating double in python results in integer, while AM calc'ing produces decim</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculating-double-in-python-results-in-integer/m-p/661390#M22020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Python is kinda weird with division, and will return an integer anytime all the inputs are integer (example: 3/2 = 1). The trick is to just force one of the variables to be a decimal (aka float). (example: 3/float(2) = 1.5). Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.calculatefield_management ("highway", "minutes", "!length_mile!*float(60)/!minutes!","PYTHON")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jul 2010 02:56:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculating-double-in-python-results-in-integer/m-p/661390#M22020</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-07-27T02:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating double in python results in integer, while AM calc'ing produces decim</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculating-double-in-python-results-in-integer/m-p/661391#M22021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;or more simply, put 60.0 in the line to enforce floating point division&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jul 2010 09:21:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculating-double-in-python-results-in-integer/m-p/661391#M22021</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2010-07-27T09:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating double in python results in integer, while AM calc'ing produces decim</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/calculating-double-in-python-results-in-integer/m-p/661392#M22022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great, thank you Chris and Dan for your replies and solutions.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Janice Poehlman&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wisconsin DNR&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;P.s. the application is drive-time analysis for recreation land profiles and guidance for funding priorities.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Jul 2010 13:23:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/calculating-double-in-python-results-in-integer/m-p/661392#M22022</guid>
      <dc:creator>JanicePoehlman</dc:creator>
      <dc:date>2010-07-27T13:23:21Z</dc:date>
    </item>
  </channel>
</rss>

