Splunk Search

Wrong results on stats sum or addcoltotals upon reaching 13th decimal value and beyond

rajyah
Communicator

Hi,

The screenshot presented below shows that there are 2 pairs that negates each other which should equal to 0 on column1, same with column2. With that in mind, the total value should be 0, right? But upon rounding it up to 13th decimal value and beyond, it no longer equates to 0.

Negative.PNG

 

 

I've attached a search query that will replicate the said issue stated above.

 

 

 

| makeresults
| eval column1=600.0000
| append
    [| makeresults
    | eval column1=390.0000]
| append
    [| makeresults
    | eval column1=355.0000]
| append
    [| makeresults
    | eval column1=575.0000]
| append
    [| makeresults
    | eval column1=355.0000]
| append
    [| makeresults
    | eval column1=590.0000]
| append
    [| makeresults
    | eval column1=600.0000]
| append
    [| makeresults
    | eval column1=355.0000]
| append
    [| makeresults
    | eval column1=-600.0000]
| append
    [| makeresults
    | eval column1=-590.0000]
| append
    [| makeresults
    | eval column1=-355.0000]
| append
    [| makeresults
    | eval column1=-575.0000]
| append
    [| makeresults
    | eval column1=-355.0000]
| append
    [| makeresults
    | eval column1=-390.0000]
| append
    [| makeresults
    | eval column1=-600.0000]
| append
    [| makeresults
    | eval column1=-355.0000]
| eval column2=round(column1/1.12,20) , column1=round(column1,20)
| addcoltotals

 

 

Thank you.

 

Regards,

Raj

Labels (1)
0 Karma

FrankVl
Ultra Champion

My first guess would be that this is the magic of floating point numbers at work. If you're having real life issues like the example you shared, you might want to look at using the sigfig() function: https://docs.splunk.com/Documentation/Splunk/8.0.5/SearchReference/MathematicalFunctions#sigfig.28X....

0 Karma

rajyah
Communicator

So it seems it's really a 'magical'  number then. Thank you sir for your reply.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting V2

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...