<?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: Round problem in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137250#M37603</link>
    <description>&lt;P&gt;The documentation for the round() function does not mention use of negative values for the second argument.  Based on that and your experience, I conclude they are not supported.&lt;/P&gt;</description>
    <pubDate>Fri, 28 Nov 2014 14:06:46 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2014-11-28T14:06:46Z</dc:date>
    <item>
      <title>Round problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137247#M37600</link>
      <description>&lt;P&gt;When I enter this query:&lt;/P&gt;

&lt;P&gt;index=_internal | head 100 | eval time1=round(_time,0) | eval time2=round(_time,-3) | eval time3=round(_time,-2) | eval time4=round(_time,-1) | eval time5=round(987987778768,-4) | table time1,time2,time3,time4,time5&lt;/P&gt;

&lt;P&gt;I get -nan in columns when second parameter of round function is less than -2.&lt;BR /&gt;
When -2 , everything is rounded to the -2 place after the dot (it equals second place beforce the dot)&lt;/P&gt;

&lt;P&gt;Could you explain why?&lt;BR /&gt;
Is this bug or a feature? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:16:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137247#M37600</guid>
      <dc:creator>lukasz92</dc:creator>
      <dc:date>2020-09-28T18:16:34Z</dc:date>
    </item>
    <item>
      <title>Re: Round problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137248#M37601</link>
      <description>&lt;P&gt;What's the idea with supplying a negative integer there at all?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2014 13:03:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137248#M37601</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2014-11-28T13:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Round problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137249#M37602</link>
      <description>&lt;P&gt;negative integer after a dot = positive integer before a dot - isn't it logic?&lt;BR /&gt;
I want to round a number to thousands (1345 -&amp;gt; 1000 ; 1501 -&amp;gt; 2000).&lt;BR /&gt;
Syntax &lt;STRONG&gt;round(1345/1000,0)*1000&lt;/STRONG&gt; is uglier&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2014 13:42:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137249#M37602</guid>
      <dc:creator>lukasz92</dc:creator>
      <dc:date>2014-11-28T13:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Round problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137250#M37603</link>
      <description>&lt;P&gt;The documentation for the round() function does not mention use of negative values for the second argument.  Based on that and your experience, I conclude they are not supported.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2014 14:06:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137250#M37603</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-11-28T14:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Round problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137251#M37604</link>
      <description>&lt;P&gt;To get around the syntax ugliness you can define a macro &lt;CODE&gt;round(2)&lt;/CODE&gt; with arguments &lt;CODE&gt;$x$,$y$&lt;/CODE&gt; as &lt;CODE&gt;(round($x$*pow(10,$y$))/pow(10,$y$))&lt;/CODE&gt; and call that like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval time2 = `round(_time, -3)` | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Nov 2014 23:19:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137251#M37604</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-11-28T23:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Round problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137252#M37605</link>
      <description>&lt;P&gt;Solution works, but I think this is a faulty function.&lt;BR /&gt;
Could I trust "pow", or there are another crazy limitations I don't know? &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;It is not documented what the second parameter should look like,&lt;BR /&gt;
@richgalloway comment should definetly appear in the official documentation.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2014 11:23:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137252#M37605</guid>
      <dc:creator>lukasz92</dc:creator>
      <dc:date>2014-12-01T11:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Round problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137253#M37606</link>
      <description>&lt;P&gt;I disagree with that interpretation. The documentation states:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;This function takes one or two numeric arguments X and Y, returning X rounded to the amount of decimal places specified by Y.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It makes no sense in this context to mention negative integers at all.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2014 12:05:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137253#M37606</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2014-12-01T12:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Round problem</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137254#M37607</link>
      <description>&lt;P&gt;Shouldn't args be tested for invalid values?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2014 12:23:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Round-problem/m-p/137254#M37607</guid>
      <dc:creator>lukasz92</dc:creator>
      <dc:date>2014-12-01T12:23:27Z</dc:date>
    </item>
  </channel>
</rss>

