Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Alternatives better to the binary "0b..." format?

+0
−0

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 :).

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

This post was sourced from https://writers.stackexchange.com/q/33563. It is licensed under CC BY-SA 3.0.

0 comment threads

2 answers

You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.

+0
−0

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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

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.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

This post was sourced from https://writers.stackexchange.com/a/33564. It is licensed under CC BY-SA 3.0.

0 comment threads

Sign up to answer this question »