- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to convert a decimal number to binary?
daniel333
Builder
05-24-2016
12:00 PM
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)
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

woodcock
Esteemed Legend
05-24-2016
12:08 PM
This can be done with tonumber
:
mysearch | eval test=tonumber(mybase10number, 2)
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jodge
Path Finder
11-18-2016
01:25 AM
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)
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

ppablo
Retired
05-24-2016
12:06 PM
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
