Answers for "Is there a way to check a particular bit in a field that returns a hex value?"
https://answers.splunk.com/answers/236506/is-there-a-way-to-check-a-particular-bit-in-a-fiel.html
The latest answers for the question "Is there a way to check a particular bit in a field that returns a hex value?"Answer by martin_mueller
https://answers.splunk.com/answering/236510/view.html
With a bit of limboing around the lack of bitwise operations, sure.
| stats count as number | eval number = mvrange(0,256) | mvexpand number | eval n = mvrange(0,8) | mvexpand n
| eval hex = tostring(number, "hex") | eval dec = tonumber(hex, 16)
| eval nth_bit = floor(number / pow(2, n)) % 2
The first line sets up a 100% test coverage data set: 256 numbers and one row for each bit to test.
The second line shows how you can convert between hexadecimal and decimal.
The last line does the actual testing, `nth_bit` will be 1 iff the `n`th bit of `number` is set.
From a bitwise perspective, this is basically `(number >> n) & 1`Sat, 16 May 2015 17:53:30 GMTmartin_mueller