<?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: How to convert scientific notation to decimal? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-scientific-notation-to-decimal/m-p/98512#M25359</link>
    <description>&lt;P&gt;&lt;CODE&gt;tonumber()&lt;/CODE&gt; call works now in 6.x&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval sci_no="7.6e+02" | eval result=tonumber(sci_no) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;yields result of &lt;CODE&gt;760&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Apr 2014 22:33:46 GMT</pubDate>
    <dc:creator>tchen_splunk</dc:creator>
    <dc:date>2014-04-10T22:33:46Z</dc:date>
    <item>
      <title>How to convert scientific notation to decimal?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-scientific-notation-to-decimal/m-p/98510#M25357</link>
      <description>&lt;P&gt;We log several values in scientific notation and wanted to know if anybody has used Splunk to convert these values to decimals.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2011 17:25:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-scientific-notation-to-decimal/m-p/98510#M25357</guid>
      <dc:creator>kbecker</dc:creator>
      <dc:date>2011-10-26T17:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert scientific notation to decimal?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-scientific-notation-to-decimal/m-p/98511#M25358</link>
      <description>&lt;P&gt;It's a bit of a pain, and I haven't fully tested it, but try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your-search-here | eval parts = split(input,"E") | eval part1 = tonumber(mvindex(parts,0)) | eval part2 = tonumber(mvindex(parts,1)) | eval dec = exact((part1) * pow(10,part2)) | fields - parts part1 part2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Substitute the name of your field for &lt;STRONG&gt;input&lt;/STRONG&gt; in the search, and the resulting number number will be found in the &lt;STRONG&gt;dec&lt;/STRONG&gt; field.&lt;/P&gt;

&lt;P&gt;Now, I don't think that you want to type this in every time!  So, create a macro.  Here's how in the manual &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/User/CreateAndUseSearchMacros"&gt;Create and Use Search Macros&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Put the following into the macro definition:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eval parts = split($input$,"E") | eval part1 = tonumber(mvindex(parts,0)) | eval part2 = tonumber(mvindex(parts,1)) | eval $dec$ = exact((part1) * pow(10,part2)) | fields - parts part1 part2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Notice that I've modified the string slightly so that it becomes a macro with two arguments:&lt;BR /&gt;&lt;BR /&gt;
&lt;STRONG&gt;input&lt;/STRONG&gt; - the name of the field that contains the string (the number in scientific notation&lt;BR /&gt;&lt;BR /&gt;
&lt;STRONG&gt;dec&lt;/STRONG&gt; - the name of the field that will contain the resulting decimal number&lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;If you name the macro &lt;CODE&gt;convert&lt;/CODE&gt;, then you can use it like this&lt;/P&gt;

&lt;P&gt;your-search-here | `convert(sciNum,decNum)` | table sciNum, decNum&lt;/P&gt;

&lt;P&gt;Note the use of the back-quote, not the single quote, around the macro. In the example, sciNum must be the name of your existing field. decNum will be created if it does not already exist.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2011 09:10:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-scientific-notation-to-decimal/m-p/98511#M25358</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2011-10-27T09:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert scientific notation to decimal?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-scientific-notation-to-decimal/m-p/98512#M25359</link>
      <description>&lt;P&gt;&lt;CODE&gt;tonumber()&lt;/CODE&gt; call works now in 6.x&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval sci_no="7.6e+02" | eval result=tonumber(sci_no) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;yields result of &lt;CODE&gt;760&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2014 22:33:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-scientific-notation-to-decimal/m-p/98512#M25359</guid>
      <dc:creator>tchen_splunk</dc:creator>
      <dc:date>2014-04-10T22:33:46Z</dc:date>
    </item>
  </channel>
</rss>

