10

Counting to 7 in binary looks like this:

0 1 10 11 100 101 110 111

The highest value is always to the left. But would it make more sense to to it like this? Is there a way that this was picked, or was it a random decision?

0 1 01 11 001 101 011 111

chr
  • 117

2 Answers2

28

It's an arbitrary convention that we write 42 to mean 4 tens and 2 ones, as opposed to 4 ones and 2 tens. Somewhere down the line it was decided, and we've been stuck with it ever since. The way binary numbers (base 2) are represented follows the convention for base 10 numbers: the binary number 110 represents 1 four, 1 two, and 0 ones.

The convention of writing the most significant bits first is called big-endian bit order, while the reverse convention is called little-endian.

  • 4
    I would say your use of the word "mirrors" is open to misinterpretation here! I suggest "follows". – TonyK Feb 18 '16 at 20:11
  • 2
    Good catch! Edited. – Lothar Narins Feb 18 '16 at 20:16
  • @LotharNarins Nice choice of number for an example. – GaussTheBauss Feb 18 '16 at 20:24
  • 3
    As mentioned by @NobodyNada and others, endianness refers to byte (or word) order, not bit order. But otherwise you're right and it's a very similar idea. See https://en.wikipedia.org/wiki/Endianness – Vaz Feb 18 '16 at 22:10
  • 2
    @Vaz although some do call it bit endianness – null Feb 18 '16 at 23:05
  • 5
    "Endianness" is also used to refer to dates (with the US format being called "middle-endian"). The term was coined to refer to byte-order for machine storage and transmission, but its extension to positional notations in general is so obvious as to be unavoidable. – Steve Jessop Feb 18 '16 at 23:19
  • 2
    Echoing Vaz and null, I would strongly encourage you to write something like "big-endian bit order" instead of just "big-endian," because the OP asked specifically about the ordering of bits in a byte, which is not affected by word endianness. I wouldn't begrudge you the casual phrasing if the questions were anything else, but this particular question is right at the sweet spot for confusion... – Vectornaut Feb 18 '16 at 23:43
  • Alright, edited. – Lothar Narins Feb 18 '16 at 23:45
  • 4
    The question doesn't mention bits in a byte. It doesn't mention bytes at all, and this is math.SE, not Stack Overflow. It's about writing numbers in binary in English text, it's not a question about computer storage. If it was about bytes, then arguably counting doesn't look like $0, 1, 10, 11$, as stated in the question. Instead it looks like 00000000, 00000001, 00000010, 00000011 :-) – Steve Jessop Feb 19 '16 at 03:05
13

You might as well have asked why are decimal numbers ordered the way they are, that is, "four hundred and forty two" is written like this: 442 (least significant digit to most significant digit from right to left).

It might seem counter-intuitive at first because Latin languages are written from left to right, however, if you investigate further you'll find that the modern number system was based on Arabic language (and then developed to be closer to what it is today), And Arabic is a language that's written from right to left. (correct me if I'm wrong though)

So this rule really follows any number system: significance of the digits is in ascending order from right to left.

EDIT: Apparently (as per the comments) the right-to-left convention had even existed way earlier than that: http://www-groups.dcs.st-and.ac.uk/history/HistTopics/Babylonian_numerals.html

  • 1
    Although Arabic as a whole is indeed written right to left, numbers are written big-endian, which makes some sense since Arabic numbers were themselves borrowed from India, where they are also big-endian. – amd Feb 18 '16 at 21:03
  • 1
    AFAIK, this question has nothing to do with big or little endian as these are schemes of storing data in computer memory. Not a single bit of the question is suggesting that the OP is talking about computation at all. So my answer is more on the general sense. I really am confused as to why people are mentioning it. Maybe I don't fully understand what's meant by endianness. – Ahmed Elyamani Feb 18 '16 at 21:08
  • 2
    They’re just using it a shorthand for “written with the most significant digit first” and “written with the least significant digit first.” The parallel with storage order within computer memory should be obvious. – amd Feb 18 '16 at 21:09
  • 2
    @amd: Careful, though: it's my understanding that "big-endian" and "little-endian" refer to the ordering of words, not the ordering of bits, so the terms are only really apropos in this discussion if you think in base 256, where a word is a single digit. The confusion is exacerbated by the fact that the OP is asking specifically about the ordering of bits in a byte, which is not affected by endianness. – Vectornaut Feb 18 '16 at 23:32
  • 2
    The Indians wrote numbers the same way we do, with the highest unit on the left; note that Indic writing systems are left-to-right. This has to do with how numbers are named; in indoeuropean languages, the higher unit generally comes first. The Arabs borrowed the system and continued writing the same way, because their language names numbers starting from the lower unit. When Fibonacci took the system to Europe, he didn't change the direction in writing numbers. – egreg Feb 18 '16 at 23:55
  • I should really have written “little-endian” above, since the first digit encountered is the least significant when encountered reading right to left. :) – amd Feb 19 '16 at 00:14
  • @Vectornaut Some of both, actually. I refer you all to the Endian Wars paper from the dim, dark days of the Internet: https://www.ietf.org/rfc/ien/ien137.txt. – amd Feb 19 '16 at 00:21
  • 1
    Before arabic numbers, Romans were already writting numbers from left to right (with a slightly different positional system). Also, I am not sure that it is that counter-intuitive: by reading from left-to-right, you quickly know the first digit, and your eyes can estimate the length of the number, so you can have an order of the size of the number in a glance. – Taladris Feb 19 '16 at 00:41
  • 1
    @Taladris: Babylonian sexagesimal had units on the right before the Romans and was more of a positional system: http://www-groups.dcs.st-and.ac.uk/history/HistTopics/Babylonian_numerals.html – Henry Feb 19 '16 at 00:50
  • @Henry: And, notably, Babylonian cuneiform was written left-to-right. (Or sometimes top-down; but in any case, the Babylonian number system was big-endian, i.e. the most significant digit was written first.) – Ilmari Karonen Feb 19 '16 at 02:14
  • What's counter-intuitive? We write "123" and say "one hundred and twenty three": the digits are written in the same order that they're spoken in. – David Richerby Feb 19 '16 at 02:28
  • 1
    @DavidRicherby: Except that we used to say "three and twenty" instead of "twenty three". A memory of this is fossilized in our numbers "thirteen", "fourteen" and so on. – J W Feb 19 '16 at 06:04
  • @JW OK, great, but we don't say that any more. What's counterintuitive today about writing numbers in the same order as we speak them? – David Richerby Feb 19 '16 at 06:09
  • @DavidRicherby: Today, nothing counterintuitive really. – J W Feb 19 '16 at 06:15
  • So would it be accurate to say it's not about the endianness of the bits, but the Indianness of the bits? – MichaelS Feb 19 '16 at 08:19