Alternatives better to the binary "0b..." format?
In our documentation, we write binary numbers like this: 1010
But we write hexadecimal numbers like this: 0xABAB
Now, according to the GCC compiler conventions:
- Numbers are normally written in decimal.
- Binary numbers are preceded by 0b.
- Hexadecimal numbers are preceded by 0x.
But in my mind, writing binary numbers as 0b1010 just looks wrong. But I can't tell my writers "don't do it because it looks wrong", especially because we write the hex numbers with a 0x prefix.
Are there any programmers out there who can weigh in on why I shouldn't use the 0b prefix? I need reinforcements :).
This post was sourced from https://writers.stackexchange.com/q/33563. It is licensed under CC BY-SA 3.0.
2 answers
As somewhat alluded to by Chenmunka, if your documentation is generally in the context of a specific programming language and/or compiler, it is probably best to stick to what is required by those. However, I think this is also somewhat dependent on why the numbers are appearing in your documentation.
If you are referencing these numbers as something would directly appear in code, you should definitely use the language's standard format for the base you're using. On the other hand, if the documentation is simply bringing up the binary representation to explain a feature or illustrate a point, I think this is less necessary, so long as it is very clear that he number is binary.
The reason for the prefixes in code is that the compiler cannot know what base you're using without a hint. 1011 is valid decimal, hexadecimal, octal, and binary, so a prefix is required to denote which is being used. In your documentation you may be introducing the number with an appropriate context that makes this unnecessary:
Assuming the following binary representation of [foo]:
10010100111010011000
We can see that it has the properties [bar] and [baz].
In this case I think the 0b
prefix would be unnecessary and possibly even make the documentation less readable, depending on the audiences familiar with programming languages.
In circumstances where large amounts of your documentation may have numbers like this, especially if the base may change depending on the context, introducing the notation early on (e.g. "We will be using the prefix "0b" to denote binary sequences and "0x" to denote hexadecimal sequences") might help as well.
This post was sourced from https://writers.stackexchange.com/a/33564. It is licensed under CC BY-SA 3.0.
0 comment threads
People will type things the way you write them in the documentation. People are looking for concrete instructions on what to do, not philosophical discussion of the working of the system.
So, enter them in the documentation the way people should enter them in the product.
0 comment threads