<?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 Currency to Two Digits After Decimal in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rounding-Currency-to-Two-Digits-After-Decimal/m-p/39593#M9042</link>
    <description>&lt;P&gt;IMHO this is completely unexpected and unwanted in the majority of cases. It is supposed this is not a framework for physical calcula...&lt;/P&gt;</description>
    <pubDate>Fri, 29 May 2015 15:55:55 GMT</pubDate>
    <dc:creator>marco_sulla</dc:creator>
    <dc:date>2015-05-29T15:55:55Z</dc:date>
    <item>
      <title>Rounding Currency to Two Digits After Decimal</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-Currency-to-Two-Digits-After-Decimal/m-p/39591#M9040</link>
      <description>&lt;P&gt;I am attempting to round my currency figures to two decimal places whether or not the amount ends with zeros (e.g., $4.00, $0.10); however, it is returning $4 and $0.1.&lt;/P&gt;

&lt;P&gt;I am using the following search command: eval cost = "$ " . tostring(round(count*.02, 2), "commas").&lt;/P&gt;</description>
      <pubDate>Sat, 05 Feb 2011 04:18:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-Currency-to-Two-Digits-After-Decimal/m-p/39591#M9040</guid>
      <dc:creator>msettipane</dc:creator>
      <dc:date>2011-02-05T04:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Currency to Two Digits After Decimal</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-Currency-to-Two-Digits-After-Decimal/m-p/39592#M9041</link>
      <description>&lt;P&gt;Doing this correctly requires some knowledge about significant figures and precision.&lt;/P&gt;

&lt;P&gt;In multiplying by the number .02 (which has 1 significant figure), you limit your result to 1 significant figure. The precision is then set from that result.&lt;/P&gt;

&lt;P&gt;What you seem to be looking for is exact arithmetic with a precision of 2. The exact() function forces a number to have maximum sigfigs and precision, while the round() function can force your precision. Assuming that count is a non-negative integer, this solution should work for you:&lt;/P&gt;

&lt;P&gt;eval cost = "$ " . tostring(round(count*exact(.02), 2), "commas")&lt;/P&gt;</description>
      <pubDate>Sat, 05 Feb 2011 04:21:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-Currency-to-Two-Digits-After-Decimal/m-p/39592#M9041</guid>
      <dc:creator>Marklar</dc:creator>
      <dc:date>2011-02-05T04:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding Currency to Two Digits After Decimal</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rounding-Currency-to-Two-Digits-After-Decimal/m-p/39593#M9042</link>
      <description>&lt;P&gt;IMHO this is completely unexpected and unwanted in the majority of cases. It is supposed this is not a framework for physical calcula...&lt;/P&gt;</description>
      <pubDate>Fri, 29 May 2015 15:55:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rounding-Currency-to-Two-Digits-After-Decimal/m-p/39593#M9042</guid>
      <dc:creator>marco_sulla</dc:creator>
      <dc:date>2015-05-29T15:55:55Z</dc:date>
    </item>
  </channel>
</rss>

