PROPOSAL: Binary Literals

Mark Thornton mthornton at
Wed Mar 25 14:14:18 PDT 2009

brucechapman at wrote:
> With all due respect, if you want to count, use decimals. Hexadecimal and binary
> are useful ways of representing patterns of bits. When the pattern of bits is
> some identifier such as a tag in tag, length, value encoded messages hex makes
> an easily recognisable representation. When the pattern is a bit mask then
> binary is probably a better representation.
> If I want to extract the 3rd, 4th and 5th bit (of 1 through 8) from a byte value
> which of these captures that intent best, or put it another way, which of these
> code extracts allows you to see most easily that bits 3,4 and 5 are being extracted?
> (b & 0b00011100) >> 2
> (b & 0x1C) >> 2
> (b & 28) >> 2
(b >> 2) & 7

is even better in my opinion. OK, so this only applies to contiguous bit 
fields, but perhaps that is most of the use case.

Mark Thornton

More information about the coin-dev mailing list