<?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: tonumber() not working on scientific notation in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working-on-scientific-notation/m-p/301592#M175014</link>
    <description>&lt;P&gt;HI 999chris&lt;/P&gt;

&lt;P&gt;you can try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults |eval incStart= "1.4848974e+12" 
 |fieldformat incStartint =tonumber(incStart)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but you can't use fieldformat to do this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults |eval incStart= "1.4848974e+12" | eval inStart1="1.23457e+10"
 |foreach inStart[fieldformat &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=tonumber(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have more column to number ,you can try this search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults |eval incStart= "1.4848974e+12" | eval inStart1="1.23457e+10"
 |foreach inStart[fieldformat &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=tonumber(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 30 Apr 2017 07:59:42 GMT</pubDate>
    <dc:creator>laudai</dc:creator>
    <dc:date>2017-04-30T07:59:42Z</dc:date>
    <item>
      <title>tonumber() not working on scientific notation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working-on-scientific-notation/m-p/301590#M175012</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I am indexing a file with JSON and epoch values on the JSON are written in scientific notation&lt;/P&gt;

&lt;P&gt;An example of a field I that is parsed by Splunk:&lt;/P&gt;

&lt;P&gt;incStart: "1.4848974e+12"&lt;/P&gt;

&lt;P&gt;Which is seen as a string.  In the event view window however it is show as an integer (or long): &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/2705i8CFF3B8338A25D8A/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
I've seen using  &lt;CODE&gt;eval incStartInt = tonumber(incStart)&lt;/CODE&gt; should work, but its not creating a new field with the value as an integer.&lt;/P&gt;

&lt;P&gt;Am I doing something wrong? I'm using Splunk 6.5.2&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 06:16:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working-on-scientific-notation/m-p/301590#M175012</guid>
      <dc:creator>999chris</dc:creator>
      <dc:date>2017-04-04T06:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: tonumber() not working on scientific notation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working-on-scientific-notation/m-p/301591#M175013</link>
      <description>&lt;P&gt;This works for me: &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/2704iEA2894117D5E05CB/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;Are you sure the field as it is extracted from JSON is in fact a string (i.e. is shown in the list of interesting fields with a 'a' prefix)?&lt;BR /&gt;
If it is extracted as a number (which would make sense, given the value), the event viewer value is simply wrong (assuming it is from the same event than your example string representation.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 07:11:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working-on-scientific-notation/m-p/301591#M175013</guid>
      <dc:creator>s2_splunk</dc:creator>
      <dc:date>2017-04-04T07:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: tonumber() not working on scientific notation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working-on-scientific-notation/m-p/301592#M175014</link>
      <description>&lt;P&gt;HI 999chris&lt;/P&gt;

&lt;P&gt;you can try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults |eval incStart= "1.4848974e+12" 
 |fieldformat incStartint =tonumber(incStart)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but you can't use fieldformat to do this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults |eval incStart= "1.4848974e+12" | eval inStart1="1.23457e+10"
 |foreach inStart[fieldformat &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=tonumber(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have more column to number ,you can try this search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults |eval incStart= "1.4848974e+12" | eval inStart1="1.23457e+10"
 |foreach inStart[fieldformat &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=tonumber(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 30 Apr 2017 07:59:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working-on-scientific-notation/m-p/301592#M175014</guid>
      <dc:creator>laudai</dc:creator>
      <dc:date>2017-04-30T07:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: tonumber() not working on scientific notation</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working-on-scientific-notation/m-p/301593#M175015</link>
      <description>&lt;P&gt;You wrote:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;I am indexing a file with JSON&lt;BR /&gt;
...&lt;BR /&gt;
&lt;CODE&gt;incStart: "1.4848974e+12"&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I'm curious. I doubt that this is a verbatim example of the JSON in the input file, because &lt;EM&gt;it's not JSON&lt;/EM&gt;: in JSON—as opposed to a JavaScript object literal—you must enclose property names, such as &lt;CODE&gt;incStart&lt;/CODE&gt;, in quotes.&lt;/P&gt;

&lt;P&gt;And then, you enclose the numeric value in quotes, as if it were a string value. Are you really enclosing that value in quotes in the JSON (JSON Lines?) input file?&lt;/P&gt;

&lt;P&gt;If so—and if you have any control over the format of that input file—then do this instead:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;"incStart": 1.4848974e+12&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Splunk (I'm currently using 7.3) correctly ingests such numbers in scientific notation in JSON.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 02:04:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tonumber-not-working-on-scientific-notation/m-p/301593#M175015</guid>
      <dc:creator>Graham_Hanningt</dc:creator>
      <dc:date>2019-09-25T02:04:37Z</dc:date>
    </item>
  </channel>
</rss>

