Splunk Search

How to convert a decimal number to binary?

daniel333
Builder

All,

Assuming Splunk has a function for this. But for the life of me I can't find it. Is there a tool to convert decimal numbers to binary? Assuming something like this exists:

mysearch | eval test=tobinary(mybase10number)

woodcock
Esteemed Legend

This can be done with tonumber:

mysearch | eval test=tonumber(mybase10number, 2)
0 Karma

Jodge
Path Finder

Unfortunately tonumber(mybase10number, 2) converts binary to decimal and not the other way around. So in the following example, the result in 'test' would be 5.

 mysearch | eval mybase2number=101 | eval test=tonumber(mybase2number, 2)
0 Karma

ppablo
Retired

Hi @daniel333

This answer by @javiergn on a previous question might be the solution you're looking for:
https://answers.splunk.com/answers/396201/how-to-convert-ip-address-to-binary.html

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...