3 ms·
For the people down voting this post, please see https://xkcd.com/1053/ https://xkcd.com/1053/ The formula is like that because there are 3 bits of information
by andyjpb 7y ago
For the people down voting this post, please see https://xkcd.com/1053/ https://xkcd.com/1053/
The formula is like that because there are 3 bits of information in the Severity Level field: it has 8 values (0->7), and 2^3 = 8.
Multiplying the Facility Number by 8 (or, equivalently, by 2^3 or by left shifting the number by 3), frees up the bottom 3 bits.
This is the same operation as you are suggesting to do in base-10: multiply by 10^3 to free up the bottom 3 digits, but for base-2 (i.e. in binary).
When the Facility Number has been moved out of the bottom 3 bits you can add in the Severity Level and get a combined value for both.
It's true that it's not very intuitive when they then render the resulting number in base-10 / decimal, however, it does get you the most compact encoding given the size of the two fields.
As another poster says, if the number had been rendered in octal (base-8) then the Severity Level would be the right-most number in the series.
- grepthisab 7y agoHey thanks this is really helpful, appreciate you taking the time to explain.