<?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: Rounding decimals up using the field calculator in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4102#M376</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am experiencing the same issue where I need to round even numbers (ie 56.5) up and have tried the following script in the field calculator (using Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;parser) but it returns an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;round(!A!* !B! /10.0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not really up with Python so not sure what needs to be changed in the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Mar 2012 22:45:51 GMT</pubDate>
    <dc:creator>ChrisGraves</dc:creator>
    <dc:date>2012-03-14T22:45:51Z</dc:date>
    <item>
      <title>Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4093#M367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm new to python and couldn't find an answer elsewhere to this problem. And I guess it's not a big deal actually, but I just don't get it... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def tvol(a, b, area):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if (a &amp;gt;=2):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; return a*b/100&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tvol(!a!, !b!, !AREA!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do I get rounded values in the end, like VB would do. F. ex. 35.5 --&amp;gt; 36 and not 35, 35.4 --&amp;gt; 35.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Someone having an idea how to put this into the above script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2011 08:48:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4093#M367</guid>
      <dc:creator>EdelSødal_Pedersen</dc:creator>
      <dc:date>2011-02-23T08:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4094#M368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;did you play around with python's round and/or int methods?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2011 10:20:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4094#M368</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-02-23T10:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4095#M369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def tvol(a, b, area):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if (a &amp;gt;=2):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;return round (a*b/100), 2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script works, but still the result is the same, because I think it's the standard of python to round that way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I found some other infos arround that using ROUND_HALF_UP etc. or as described here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/library/decimal.html"&gt;http://docs.python.org/library/decimal.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I can't transfere the idea to the field calculator... :confused:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2011 10:38:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4095#M369</guid>
      <dc:creator>EdelSødal_Pedersen</dc:creator>
      <dc:date>2011-02-23T10:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4096#M370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;try this...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def tvol(a, b, area):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (a &amp;gt;=2):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return int(round(a*b/100))&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Feb 2011 14:47:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4096#M370</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2011-02-23T14:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4097#M371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the hint, but unfortunately I get the same result ... :confused:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 05:26:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4097#M371</guid>
      <dc:creator>EdelSødal_Pedersen</dc:creator>
      <dc:date>2011-02-24T05:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4098#M372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Never tried it, but it looks like some variation on ceiling may be available&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/library/math.html"&gt;http://docs.python.org/library/math.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 05:54:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4098#M372</guid>
      <dc:creator>MichaelStead</dc:creator>
      <dc:date>2011-02-24T05:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4099#M373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the link. math.ceil() really should do the trick!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's also explained in section 5.4 here: &lt;/SPAN&gt;&lt;A href="http://docs.python.org/library/stdtypes.html"&gt;http://docs.python.org/library/stdtypes.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But this is really weird.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've defined 3 new fields in the table just to make sure it's the right field type. So I have three fields &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;A&lt;/SPAN&gt;&lt;SPAN&gt; ,&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;B&lt;/SPAN&gt;&lt;SPAN&gt; and C, all are double.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The script for field c:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;math.ceil ( !A! * !B! /10)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A=43, B=2 and I get C=8 (8.6, should result in 9)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Even if I just calculate !A! * !B! /10 within the field calculator, I do not even get decimals here (8.6, just returning &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I'm wondering if there are some generell adjustments somewhere ... which are not correct &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 07:11:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4099#M373</guid>
      <dc:creator>EdelSødal_Pedersen</dc:creator>
      <dc:date>2011-02-24T07:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4100#M374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;to avoid integer division, one of the inputs must be cast as a float and the simplest way to do that in your case is to divide by 10.0 not 10&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 07:51:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4100#M374</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-02-24T07:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4101#M375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Thanks!&lt;/STRONG&gt;&lt;SPAN&gt; &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Never would have figured out that it would be 10.0 instead of 10!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;round(!A!* !B! /10.0) is giving the result I was looking for!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks and a nice day to all of you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Feb 2011 08:06:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4101#M375</guid>
      <dc:creator>EdelSødal_Pedersen</dc:creator>
      <dc:date>2011-02-24T08:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4102#M376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am experiencing the same issue where I need to round even numbers (ie 56.5) up and have tried the following script in the field calculator (using Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;parser) but it returns an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;round(!A!* !B! /10.0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not really up with Python so not sure what needs to be changed in the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2012 22:45:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4102#M376</guid>
      <dc:creator>ChrisGraves</dc:creator>
      <dc:date>2012-03-14T22:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4103#M377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;replace the !A! and !B! with the fieldnames you want to use for the calculation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want results without decimals use: round(!A!* !B! /10) and with decimal places: round(!A!* !B! /10.0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;10.0 could be any number you want to use, you just have to define the number of decimals, even if the field type is double and allows more decimals the script will not return more than what you have defined within the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2012 05:35:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4103#M377</guid>
      <dc:creator>EdelSødal_Pedersen</dc:creator>
      <dc:date>2012-03-15T05:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding decimals up using the field calculator</title>
      <link>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4104#M378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Iris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your reply this has given me what I need and I've learn't something too!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have a good day.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thankyou,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2012 21:57:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/rounding-decimals-up-using-the-field-calculator/m-p/4104#M378</guid>
      <dc:creator>ChrisGraves</dc:creator>
      <dc:date>2012-03-15T21:57:25Z</dc:date>
    </item>
  </channel>
</rss>

