bell notificationshomepageloginNewPostedit profile

Topic : Re: 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 - selfpublishingguru.com

10% popularity

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.


Load Full (0)

Login to follow topic

More posts by @Reiling826

0 Comments

Sorted by latest first Latest Oldest Best

Back to top