<?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: isnum() vs. NaN in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/681882#M232999</link>
    <description>&lt;BLOCKQUOTE&gt;the text "NaN" (does occasionally happen when the source is a SQL query) either&amp;nbsp;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This explains it. &amp;nbsp;I was wondering why &lt;FONT face="courier new,courier"&gt;typeof(num)&lt;/FONT&gt; should be Number when &lt;U&gt;num&lt;/U&gt; had value "NaN". Whoever wrote that code in typeof must have SQL in mind. &amp;nbsp;A SQL query only returns "NaN" when the data type is numeric. &amp;nbsp;If you are programming against results from a SQL query in any language, you always need to write a logic for this possible return.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Mar 2024 16:28:09 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2024-03-25T16:28:09Z</dc:date>
    <item>
      <title>isnum() vs. NaN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/679299#M232218</link>
      <description>&lt;P&gt;Has anyone run into the interesting effect that isnum() thinks that "NaN" is a number?&lt;/P&gt;
&lt;P&gt;So&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;isnum("NaN") is true
"NaN" * 2 = "NaN"&lt;/LI-CODE&gt;
&lt;P&gt;but&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;tonumber("NaN") is NULL&lt;/LI-CODE&gt;
&lt;P&gt;Are there any other odd, uh, numbers besides Not a Number?&lt;BR /&gt;&lt;BR /&gt;I made up the following silly query as an illustration:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults
| eval num="blubb;NaN;100;0.5;0,5;-0;NULL;"
| makemv delim=";" allowempty=true num 
| mvexpand num
| eval isnum=if(isnum(num),"true","false")
| eval isint=if(isint(num),"true","false")
| eval isnull=if(isnull(num),"true","false")
| eval calcnum=num*2
| eval isnumcalcnum=if(isnum(calcnum),"true","false")
| eval isnullcalcnum=if(isnull(calcnum),"true","false")
| eval numnum=tonumber(num)
| eval isnumnum=if(isnum(numnum),"true","false")
| eval isnullnumnum=if(isnull(numnum),"true","false")
| table num,isnum,isint,isnull,calcnum,isnumcalcnum,isnullcalcnum,numnum,isnumnum,isnullnumnum&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;which results in&lt;/P&gt;
&lt;TABLE border="1" width="63.11896076589446%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="6.709677419354838%"&gt;num&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;isnum&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;isint&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;isnull&lt;/TD&gt;
&lt;TD width="8.38709677419355%"&gt;calcnum&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;isnumcalcnum&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;isnullcalcnum&lt;/TD&gt;
&lt;TD width="8.258064516129032%"&gt;numnum&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;isnumnum&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;isnullnumnum&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="6.709677419354838%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.38709677419355%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.258064516129032%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="6.709677419354838%"&gt;blubb&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="8.38709677419355%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.258064516129032%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="6.709677419354838%"&gt;NaN&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;true&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="8.38709677419355%"&gt;NaN&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.258064516129032%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="6.709677419354838%"&gt;100&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;true&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;true&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="8.38709677419355%"&gt;200&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.258064516129032%"&gt;100&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="6.709677419354838%"&gt;0.5&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;true&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="8.38709677419355%"&gt;1&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.258064516129032%"&gt;0.5&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="6.709677419354838%"&gt;0,5&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="8.38709677419355%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.258064516129032%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="6.709677419354838%"&gt;-0&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;true&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;true&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="8.38709677419355%"&gt;-0&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.258064516129032%"&gt;-0&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="6.709677419354838%"&gt;NULL&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="8.38709677419355%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.258064516129032%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="6.709677419354838%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="5.806451612903226%"&gt;false&lt;/TD&gt;
&lt;TD width="8.38709677419355%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;TD width="8.258064516129032%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;false&lt;/TD&gt;
&lt;TD width="8.516129032258064%"&gt;true&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;BR /&gt;(Post moved over from the Splunk Enterprise group.)&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 16:54:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/679299#M232218</guid>
      <dc:creator>bochmann</dc:creator>
      <dc:date>2024-03-01T16:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: isnum() vs. NaN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/679312#M232221</link>
      <description>&lt;P&gt;Smells like a bug to me.&amp;nbsp; Consider reporting it to Splunk Support and/or &lt;A href="https://ideas.splunk.com" target="_blank"&gt;https://ideas.splunk.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 16:01:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/679312#M232221</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-03-01T16:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: isnum() vs. NaN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/681820#M232982</link>
      <description>&lt;P&gt;So, I've been talking to Splunk support, which directed me to the documentation at&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.2.0/SearchReference/Eval#:~:text=Numeric%20calculations,a%20null%20field" target="_self"&gt;SearchReference/Eval&lt;/A&gt;&amp;nbsp; that kind of mentions that NaN is special, and also pointed to typeof() as alternative.&lt;/P&gt;&lt;P&gt;Initially, this seemed like a good idea, but unfortunately typeof() is even more interesting:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval t=typeof("NaN")
| eval num="NaN"
| eval tnum=typeof(num)&lt;/LI-CODE&gt;&lt;P&gt;...returns&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;t = String&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;tnum = Number&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Oh well....?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 08:32:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/681820#M232982</guid>
      <dc:creator>bochmann</dc:creator>
      <dc:date>2024-03-25T08:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: isnum() vs. NaN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/681822#M232984</link>
      <description>&lt;P&gt;Support is correct that documented behavior is not a bug. &amp;nbsp;That explains your original observation about tonumber.&lt;/P&gt;&lt;P&gt;Your observation about typeof is also normal. &amp;nbsp;Imagine you are the interpreter. &amp;nbsp;In typeof("NaN"), you are given a string literal. &amp;nbsp;Of course you say that's of type String. &amp;nbsp;In typeof(num), you are given a variable whose value is documented as a number. &amp;nbsp;You say that's of type Number.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 08:42:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/681822#M232984</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-03-25T08:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: isnum() vs. NaN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/681842#M232988</link>
      <description>&lt;P&gt;Well, Splunk doesn't treat inf and -inf, mentioned in that same section, as a number either.&lt;/P&gt;&lt;P&gt;Anyways, I need to add additional logic to sanitize inputs that might have fields with the text "NaN" (does occasionally happen when the source is a SQL query) either way - for most purposes it just isn't a number, and tends to cause problems in further processing.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 10:54:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/681842#M232988</guid>
      <dc:creator>bochmann</dc:creator>
      <dc:date>2024-03-25T10:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: isnum() vs. NaN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/681882#M232999</link>
      <description>&lt;BLOCKQUOTE&gt;the text "NaN" (does occasionally happen when the source is a SQL query) either&amp;nbsp;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This explains it. &amp;nbsp;I was wondering why &lt;FONT face="courier new,courier"&gt;typeof(num)&lt;/FONT&gt; should be Number when &lt;U&gt;num&lt;/U&gt; had value "NaN". Whoever wrote that code in typeof must have SQL in mind. &amp;nbsp;A SQL query only returns "NaN" when the data type is numeric. &amp;nbsp;If you are programming against results from a SQL query in any language, you always need to write a logic for this possible return.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 16:28:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/681882#M232999</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-03-25T16:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: isnum() vs. NaN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/709540#M239806</link>
      <description>&lt;P data-unlink="true"&gt;Hi Splunk community!&lt;/P&gt;&lt;P data-unlink="true"&gt;I just want to let you know that I worked with one of our most senior engineers to update information in Splunk docs about NaN -- take a look at the info about NaN in the&amp;nbsp;&lt;STRONG&gt;isnum&lt;/STRONG&gt; and &lt;STRONG&gt;isstr&lt;/STRONG&gt; sections in &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/InformationalFunctions" target="_self"&gt;Informational functions&lt;/A&gt; in the Splunk platform &lt;EM&gt;Search Reference&lt;/EM&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;I know that playing around with NaN is irresistible, especially for our techiest Splunk experts, but the general advice from the sr engineer is to avoid using NaN in Splunk searches if possible unless you really really know what you're doing. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;--Kristina&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 23:48:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/709540#M239806</guid>
      <dc:creator>kgorzynski</dc:creator>
      <dc:date>2025-01-22T23:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: isnum() vs. NaN</title>
      <link>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/709738#M239851</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254772"&gt;@kgorzynski&lt;/a&gt;! Updated information provides much needed clarity.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 23:59:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/isnum-vs-NaN/m-p/709738#M239851</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-01-24T23:59:03Z</dc:date>
    </item>
  </channel>
</rss>

