Questions tagged [bit]

30 questions
101
votes
7 answers

What is the history of why bytes are eight bits?

What were the historical forces at work, the tradeoffs to make, in deciding to use groups of eight bits as the fundamental unit? There were machines, once upon a time, using other word sizes. But today, for non-eight-bitness, you must look to museum…
DarenW
  • 4,433
  • 3
  • 22
  • 43
55
votes
3 answers

What is the name for storing / packing many boolean states into one number?

It's a sort of simple compression where you use one numeric variable to store many boolean / binary states, using doubling and the fact that every doubling number is 1 + the sum of all the previous ones. I'm sure it must be an old, well-known…
42
votes
12 answers

Is there an alternative to bits?

Is there an alternative to bits as the smallest unit of data? Something that won't be only 0 or 1, but actually hold many possible states in between? Wouldn't it be more natural to store floats like that?
Dokkat
  • 557
  • 4
  • 6
25
votes
8 answers

Advantages and disadvantages of using bit masks in database

Not so long ago I talked to my colleague and he was definitely against using bit masks because it is hard to understand all the values that are stored in the database. In my opinion it is not always a bad idea to use them, for example to determine…
Alex Ovechkin
  • 361
  • 1
  • 3
  • 5
19
votes
4 answers

How are negative signed values stored?

I was watching this video on the maximum and minimum values of signed integers. Take an example of a positive signed value - 0000 0001 The first bit denotes that the number is positive and the last 7 bits are the number itself. So it is easily…
discussedtree
  • 319
  • 1
  • 3
  • 8
12
votes
6 answers

Is power-of-two bits per word "convenient"? If it is, why is that?

I find several sources claiming that power-of-two bits in a binary word (such as 8-bits per byte) is a "good thing" or "convenient". I find no source pointing out why. From What is the history of why bytes are eight bits? we read in the approved…
Andreas
  • 299
  • 1
  • 8
7
votes
3 answers

How does word size affect the amount of virtual address space available?

So, I should really know this stuff already, but I am starting to learn more about the lower levels of software development. I am currently reading Computer Systems: A Programmer's Perspective. by Bryant O'Hallaron. I am on chapter 2 and he is…
Luke
  • 273
  • 3
  • 8
5
votes
3 answers

Is a 'least significant bit' used anywhere practically today?

I'm working on a library that supports file reading, and right now I've always assumed that all the bytes are written in most significant bit first format. Is the least significant bit first format ever practically used anywhere today on any…
Water
  • 356
  • 1
  • 12
5
votes
1 answer

Clearing the lowest set bit of a number

I can see in this tutorial on bit manipulation, under the heading "Extracting every last bit", that - Suppose we wish to find the lowest set bit of x (which is known to be non-zero). If we subtract 1 from x then this bit is cleared, but all the…
theharshest
  • 153
  • 1
  • 4
4
votes
3 answers

Is it possible to store N bits of unique combinations, in N-1 bits? If not; why does MD5 get reprimanded for collissions?

Regarding cryptography and the issue of collisions, I posed a question as to whether it was ever possible to store every single possible combination of a bit array of a particular size, in a bit array that was at least one bit smaller, with…
Anon
  • 3,565
  • 3
  • 27
  • 45
4
votes
4 answers

Byte addressable vs bit addressable

Why are most computers byte addressable instead of bit addressable? By B/b addressable I mean that processor can operate on level of single B/b. Bit addressable advantages: Booleans have size of one bit. You can directly access single bits in…
Ford O.
  • 223
  • 2
  • 7
4
votes
1 answer

What is the difference between size and length?

It seems that the terms size and length are used interchangeably to describe how many bits, bytes or octets some data occupies, i.e. a length field in a data header is said to indicate the size of the data. Did I see this correctly? If not, how do…
user3998276
  • 187
  • 1
  • 2
  • 7
4
votes
1 answer

Endianness at bit level

I am learning the union and struct and I wrote the code below. What I do not understand is why the output is different when I change from a little endian to a big endian machine. My understanding is that endianness is important when you have more…
3
votes
5 answers

Why isn't byte | bit the only built in data type?

All languages I have seen so far have multiple builtin data types (int, double, float, char, long...). But if we look closely, they are just arbitrary arrays of bits, the only difference between them are their methods (addition, dividing, toString,…
Ford O.
  • 223
  • 2
  • 7
3
votes
2 answers

Explanation to why Counting bits set, Brian Kernighan's way works

I found this link to count number of bits in a variable. I think it is pretty cool, but I can't figure out why it works. Can someone offer an explanation? Here is the code unsigned int v; // count the number of bits set in v unsigned int c; // c…
flashburn
  • 147
  • 1
  • 8
1
2