<?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: Why is Splunk sometimes rounding to the next integer? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199903#M187532</link>
    <description>&lt;P&gt;I think only someone from the Splunk development team and explain the behavior.&lt;/P&gt;

&lt;P&gt;The rest of us should just remember to use &lt;CODE&gt;round&lt;/CODE&gt; or &lt;CODE&gt;exact&lt;/CODE&gt; if we expect decimals from an eval.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Oct 2015 15:58:30 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2015-10-26T15:58:30Z</dc:date>
    <item>
      <title>Why is Splunk sometimes rounding to the next integer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199898#M187527</link>
      <description>&lt;P&gt;Hi, I'm wondering why Splunk starts rounding to the next integer in the second row.&lt;/P&gt;

&lt;P&gt;The command behind this is just:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ....
| eval xi=x*i
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Best regards&lt;/P&gt;

&lt;P&gt;Heinz&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/759iF71044FF74642894/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Edit:&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/760i3F2B9B9947BB1BDC/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 11:06:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199898#M187527</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2015-10-26T11:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Splunk sometimes rounding to the next integer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199899#M187528</link>
      <description>&lt;P&gt;I can't explain why Splunk rounds like it does, but I have a workaround.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval xi=exact(x*i) | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Oct 2015 14:11:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199899#M187528</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-10-26T14:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Splunk sometimes rounding to the next integer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199900#M187529</link>
      <description>&lt;P&gt;Thanks for your input, I didn't know this function.&lt;/P&gt;

&lt;P&gt;This would be a workaround as well.&lt;BR /&gt;
   ...&lt;BR /&gt;
| eval xi=round(x*i, 2)&lt;/P&gt;

&lt;P&gt;I am just wondering about this implicit floor/ceil behaviour&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 14:27:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199900#M187529</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2015-10-26T14:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Splunk sometimes rounding to the next integer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199901#M187530</link>
      <description>&lt;P&gt;It does it because it is &amp;lt;1.  If it is greater-than-one, it rounds to integer.  You can control this with these commands: &lt;CODE&gt;ceil&lt;/CODE&gt;, &lt;CODE&gt;exact&lt;/CODE&gt;, &lt;CODE&gt;floor&lt;/CODE&gt;, &lt;CODE&gt;round&lt;/CODE&gt; and &lt;CODE&gt;sigfig&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 15:20:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199901#M187530</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-26T15:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Splunk sometimes rounding to the next integer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199902#M187531</link>
      <description>&lt;P&gt;And here comes another challenge:&lt;/P&gt;

&lt;P&gt;When I use&lt;/P&gt;

&lt;P&gt;| eval x=round(x, 2)&lt;BR /&gt;
| eval xi=x*i&lt;/P&gt;

&lt;P&gt;Now it starts rounding in row 12. It seems to me, that the format of x influences the rounding in xi.&lt;BR /&gt;
I've added screenshot in my question (I don't know how to upload it in the comments...)&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 15:50:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199902#M187531</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2015-10-26T15:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Splunk sometimes rounding to the next integer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199903#M187532</link>
      <description>&lt;P&gt;I think only someone from the Splunk development team and explain the behavior.&lt;/P&gt;

&lt;P&gt;The rest of us should just remember to use &lt;CODE&gt;round&lt;/CODE&gt; or &lt;CODE&gt;exact&lt;/CODE&gt; if we expect decimals from an eval.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 15:58:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199903#M187532</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2015-10-26T15:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Splunk sometimes rounding to the next integer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199904#M187533</link>
      <description>&lt;P&gt;Exactly.  It appears that &lt;CODE&gt;number&lt;/CODE&gt; values are initially &lt;CODE&gt;typeset&lt;/CODE&gt; as &lt;CODE&gt;integer&lt;/CODE&gt; so that they round to &lt;CODE&gt;integer&lt;/CODE&gt; if &amp;gt;1 but do not if &amp;lt;1.  If you use &lt;CODE&gt;round&lt;/CODE&gt; then you change the typesetting and it behaves differently after that.  It seeps that if you round with &lt;CODE&gt;2&lt;/CODE&gt; as you did, then once it has 2 significant digits, it stops keeping the decimal part.  This should probably be documented somewhere; it is interesting and can create problems, for sure.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 15:59:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199904#M187533</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-10-26T15:59:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Splunk sometimes rounding to the next integer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199905#M187534</link>
      <description>&lt;P&gt;Thanks for clarifying this behaviour.This is definitely something I have to keep in mind!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2015 09:09:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199905#M187534</guid>
      <dc:creator>HeinzWaescher</dc:creator>
      <dc:date>2015-10-27T09:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Splunk sometimes rounding to the next integer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199906#M187535</link>
      <description>&lt;P&gt;If I had to make an educated guess this behaviour actually looks like the behavior of &lt;A href="https://en.wikipedia.org/wiki/Significant_figures"&gt;Significant digits&lt;/A&gt; and &lt;A href="https://en.wikipedia.org/wiki/Significance_arithmetic"&gt;Significance arithmetic&lt;/A&gt;. When you're doing math with values that are only accurate to a specific number of places, your result can only be as accurate as the input numbers.&lt;/P&gt;

&lt;P&gt;Try these out for yourself:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1 * 0.9 = 0.9  (One significant digit on both operands, one significant digit in the result)
2 * 0.9 = 2  ( if 0.9 was exact, then we would have 1.8, however since we cannot say that by default, we need to round to 1 significant digit so 2 )
2 * 0.90 = 1.8 (The right hand side has 2 significant digits, and splunk adjusts accordingly)
2 * 0.99 = 2 ( Again if .99 was exact, then the calculation would be 1.98, but since we can only have 2 significant digits, so rounds to 2)
1000 * 0.9 = 900 (I'm not sure if splunk is treating these trailing 0s as significant or not, but in this case we still only have 1 on each side)
1100 * 0.9 = 990 (ditto but with 2 significant digits on the left hand side)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Edit to add, in fact this was previously answered by a splunker: &lt;A href="https://answers.splunk.com/answering/11400/view.html"&gt;https://answers.splunk.com/answering/11400/view.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Another edit to add: Splunk's docs used to have an explanation on this: &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.2/SearchReference/eval#Significant_figures_and_precision"&gt;http://docs.splunk.com/Documentation/Splunk/4.2/SearchReference/eval#Significant_figures_and_precision&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;But it seems the rules have changed a bit since then... so we probably need a splunk dev to clarify:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2.0 * 1024 = 2048
2.2 * 1024 = 2253 (instead of 2252.8 with an exact calculation)
2.1 * 1024 = 2150 (instead of 2150.4 with an exact calculation)
2.10 * 1024 = 2150
2.100 * 1024 = 2150
2.1000 * 1024 = 2150.4 (five significant digits on the left hand side)
2.1 * 1024.0 = 2150 (uh... wut? )
2.1 * 1024.1 = 2151 (instead of 2150.61 ) 
2.100000000 * 1024.1 = 2150.6
2.10000 * 1024.1 = 2150.6
2.10000 * 1024.10 = 2150.61
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Oct 2015 13:39:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199906#M187535</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-10-27T13:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Splunk sometimes rounding to the next integer?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199907#M187536</link>
      <description>&lt;P&gt;0.90 * 12 (both with 2 significant digits... if it was an exact calculation you'd have 10.8 (which is three significant digits)... so we have to round to 2 digits which is 11.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2015 13:46:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-Splunk-sometimes-rounding-to-the-next-integer/m-p/199907#M187536</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2015-10-27T13:46:52Z</dc:date>
    </item>
  </channel>
</rss>

