- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Edit Admin
The problem isn't, as such, people failing to distinguish between "flag in bit zero, zeroes in all other bits" versus "octet that is the whole flag".
No, it is "bit zero is on the left (most significant bit)" versus "bit zero is on the right (least significant bit)". With a bit (sorry) of the first part mixed in. Then again, we cannot tell whether the programmer is confused on "which end is bit zero" or confused on "is it a bitflag with zero on the left or is it a whole zero/one field taking the whole octet".
And don't forget the other two definitions of bit numbers in octets: bits are numbered 1 to 8 with 1 on the left versus 1 on the right, so there's no "bit zero" at all. In the past (much less today), all four schemes (0-7, 7-0, 1-8, 8-1) have been used, usually depending on the vendor that's providing the bitfields in question.
I personally prefer 7-0 (0 is LSB) because
1 << bitnumberdirectly gives the right value, but https://datatracker.ietf.org/doc/html/rfc1035 says that for RFC purposes, it's 0-7 (0 is MSB). :(Edit Admin
i find this a bit confusing
Admin
:pendant: depending on whether you're rounding to the nearest 100, this is probably always true.
Edit Admin
I think I agree. This is clearly a case of the programmer seeing that you need to set bit 0 of the flags field (8 bits) and not realising that bit 0 is the most significant bit, not the least significant bit. In particular, the paragraph in RFC6844 before the quoted paragraphs says this:
Any programmer (many of whom do understand bits, believe it or not) is going to think "bit field". But they are also going to think bit 0 is the LSB unless they are aware that things are done differently in networking.
Note that later in the RFC in section 5.1 under "syntax" we have this:
If you read the whole RFC, you will get it right. However, people clearly don't read the whole RFC.
I was going to criticise LetsEncrypt for their "work around". but what they do is safer than adhering strictly to the standard. If somebody bodges their CAA record in this way, intending it to be critical, it will still be treated as such instead of having the issuer issue a certificate it shouldn't.
Admin
It would be much more effective to put the call-to-action first in that paragraph, so that readers know it describes something they have to do, and isn't just an arcane discussion of conventions.
E.g. start with "Send a decimal value of 128, because on our conventions, bit 0 means the most significant bit..."
Admin
The fact that little endian and big endian are different things at all depending on platform is TRWTF, but I understand it is impossible to make everyone agree on that because it is not a matter of agreement, it is a matter of different aspects of computing being developed in different silos that didn't and wouldn't necessarily be expected to collaborate back in the day
Something something XKCD comic about standards
Admin
How about "if you're going to reserve 7 of 8 bits, make bit 0 the bit you actually use"? So anyone treating it as a boolean will put a 1 in the field and get it right and future users can do fancier things.
Admin
So there are two different ways to refer to different bits in an octet: by LSB to MSB, and by numbering.
Oh, wait, there are three different ways, because numbering can go 0-7 or 1-8.
If you're writing a specification that will be read by millions, clarity is achieved by specifying all three every time. E.g. "The furble bit is the MSB, bit 0 of 0-7". Irritating? Yes. But no matter which way a reader thinks about it, they will have the answer they need right in front of them, instead of having to consult RFC one thousand whatever.
Admin
Admin
Of course, I mess up the formatting when trying to be pedantic :)